enable-if

enable-if

文章 0 浏览 5

std ::有条件的编译时间继承与std :: enable_if for编译时间方法

我想设计一个模板类,其中有两个参数,这些参数是根据模板参数在汇编时间上的两个参数,这是两个相互排斥的基类之一。 我想对我来说很简单,所以提出…

逆夏时光 2025-02-07 18:48:13 2 0

了解C++ 98中的Enable_if实现

我已经将其视为 enable_if for c ++ 98 的自称实现: template struct enable_if { typedef T type; }; template struct enable_if {}; 但是,我个人…

梅倚清风 2025-02-07 03:39:27 2 0

为什么在enable_if模板构造函数中的可选参数可以帮助编译器推断模板参数?

最小的例子很短: #include #include #include struct Foo{ //template //Foo(C col, typename std::enable_if::type* = 0){ // std::cout << "option…

双马尾 2025-01-26 14:48:32 1 0

ENABL

我知道C ++编译器优先选择一个模板专业化: template class A {}; // primary template template class A, void>> { }; // specialization for floati…

莫相离 2025-01-26 02:22:11 3 0

为什么使用Sfinae代码编译错误,即使有一个可以匹配的模板

代码如下。 #include #include template struct Vec { using value_type = T; static constexpr size_t size() { return Type::size; } }; template s…

岁吢 2025-01-22 02:47:27 3 0

如何在enable_if中使用多个条件?

我有以下代码: #include #include using namespace std; enum class a : uint16_t { x, y }; template using isUint16ScopedEnum = std::integral_co…

浅浅 2025-01-21 16:42:07 2 0

C&#x2B;&#x2B;通过CRTP检测朋友课的私人成员

我有一个 CRTP 基类 (Bar),它由未指定的类继承。此派生类可能有也可能没有特定成员 (internal_foo),并且该特定成员可能有也可能没有其他成员 (test(…

杯别 2025-01-19 22:24:12 3 0

C++模板 type_trait enable_if 类是映射

#include #include #include #include #include #include using namespace std; // enable_if_t = MapType implements .find(KeyType key), .begin(),…

囚你心 2025-01-16 20:20:00 2 0

为什么enable_if_t需要有数据类型标识符和默认值?

我无法理解下面代码片段中的 2 个注释代码行与它们前面的行有何不同?有没有一种简单的方法可以理解注释行的含义与它们前面的行的含义?我无法在脑海…

心清如水 2025-01-11 03:54:58 4 0

输入具有特定成员函数的重载函数

我试图根据传入的序列容器是否将 push_back 作为成员函数来重载函数。 #include #include #include #include #include template, int> = 0> void has_…

祁梦 2025-01-10 12:44:53 4 0

不应该定义的enable_if函数

作为一个实验,我试图创建一个没有参数的 void 成员函数,根据类模板参数更改行为: #include #include template class MyClass { public: void MyFun…

淡淡の花香 2024-12-24 22:17:17 3 0

类模板的成员模板函数上的enable_if

这似乎是 MSVC10 中的一个错误? #include template struct A{ template typename std::enable_if::type t(){} }; int main(){ A().t(); //error C277…

那伤。 2024-12-21 14:53:21 4 0

根据模板参数在编译时安排类结构

C++ 中是否可以根据模板参数包含/排除成员变量? 这是一个例子: template class RealNumber { T real; }; template class ComplexNumber { T real; T…

腹黑女流氓 2024-12-15 18:18:09 7 0

enable_if :模板库的模板化方法继承多次的情况

如果我有一个带有模板方法的模板基类: template class S { public: template void f(U p, typename enable_if >::type*dummy = 0) { std::cout << p …

无言温柔 2024-12-11 07:18:03 5 0

我可以使用像enable_if这样的隐式转换运算符吗?

我有一个(基本上完成的)矩阵类(在这篇文章的后面)。如果矩阵是 1x1 矩阵,那么我希望隐式转换为支持类型(例如 1x1 浮点矩阵应转换为浮点)。 有…

妄司 2024-12-09 03:59:46 6 0
更多

推荐作者

梦断已成空

文章 0 评论 0

瞎闹

文章 0 评论 0

寄意

文章 0 评论 0

似梦非梦

文章 0 评论 0

更多

友情链接

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