template-specialization

template-specialization

文章 0 浏览 6

C++与枚举匹配的模板函数中无法解释的变化

我有以下包含模板函数的代码。当我使用第二个参数作为枚举来调用此函数时:在某些情况下,它会找到模板专业化,而在某些情况下则不会。 我已经验证枚…

过期以后 2024-10-16 20:54:09 14 0

如何仅特化模板类的某些成员?

代码: template struct A { void f1() {}; void f2() {}; }; template<> struct A { void f2() {}; }; int main() { A data; data.f1(); data.f2(); …

凉城凉梦凉人心 2024-10-16 18:35:18 14 0

部分专业化成员函数实现

我目前正在重构一些代码,明确专门化具有两个模板参数的类模板的成员函数。 template class Foo { void bar(); }; template void Foo::bar() { /* Gen…

这样的小城市 2024-10-16 08:01:37 10 0

模板通过 const 引用传递

我已经看过一些类似的问题,但我仍然很困惑。我试图弄清楚如何显式(不是通过编译器优化等)和 C++03 兼容来避免在将对象传递给专用模板时复制对象功…

深白境迁sunset 2024-10-15 11:48:00 9 0

C++具有恒定值的模板专业化

是否有一种简单的方法来定义 C++ 模板类的部分特化(给定模板参数之一的数字常量)?我试图仅为某些类型的模板组合创建特殊的构造函数: template cla…

書生途 2024-10-15 02:45:55 9 0

template-id 与任何模板声明不匹配

我遇到了令人沮丧的编译器错误,我似乎无法解决。这与模板专业化有关,但我看不出有什么问题...... ../../include/thread/lock_guard.inl:23: error: …

静若繁花 2024-10-12 09:14:28 7 0

模板的总类专业化

可以说我有一个模板类 template struct Widget { //generalized implementation } 但我想完全专业化.. 对于接受参数的模板? template <> struct Widg…

楠木可依 2024-10-11 15:03:41 11 0

C 风格字符串的模板特化

我很难获得接受常规 c 样式字符串的模板专业化的正确语法。例如 namespace RubyUtils { template VALUE toValue(const T& v); }; template<> VALUE to…

淡笑忘祈一世凡恋 2024-10-11 11:10:44 6 0

无法专门化函数模板

这是家庭作业,尽管它已经以不同的方式提交了。 我从 Visual Studio 2008 得到以下内容 error C2893: Failed to specialize function template 'void …

怂人 2024-10-10 22:46:34 14 0

从专用模板类函数调用非专用模板类函数

是否可以从专用模板类调用非专用模板类中定义的函数?这是我正在尝试的一个例子: template struct Convert { static inline void toString(unsigned …

原谅我要高飞 2024-10-10 16:25:42 10 0

静态字段初始化的模板部分特化

我正在尝试类似以下内容: struct MyType { }; template struct Test { static const MyType * const sm_object; }; template <> struct Test { stati…

Hello爱情风 2024-10-10 04:22:40 14 0

C++模板部分特化错误

下面的代码给了我一个编译错误:class Q64 is not a valid type for a templateconstant argument template INLINE T grid_residue(T amount) { T rem…

溺深海 2024-10-10 03:31:38 18 0

是否可以使用成员枚举来专门化模板?

struct Bar { enum { Special = 4 }; }; template struct Foo {}; template struct Foo {}; 用法: Foo aa; 使用 gcc 4.1.2 编译失败 它抱怨使用 T::S…

羁〃客ぐ 2024-10-09 17:07:32 10 0

这种部分模板特化有什么问题吗?

template Retval call_retval_wrapper(CallContext &callctx, Op const op, Args &...args); template bool call_retval_wrapper( CallContext &callc…

紫竹語嫣☆ 2024-10-09 07:25:10 8 0

部分专门化模板内的方法指针

我正在尝试实现具有只读、只写和读写行为的属性。我认为模板专业化将是这里的方法,所以我尝试了这个: template class Property; template class Pro…

木格 2024-10-09 01:29:41 12 0
更多

推荐作者

梦断已成空

文章 0 评论 0

瞎闹

文章 0 评论 0

寄意

文章 0 评论 0

似梦非梦

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文