[英]std::conditional with SFINAE
是否可以创建某种std :: enable_if_and_else,如std :: conditional,但对于未定义的类却没有编译时错误。
这是一个例子:
static constexpr bool myExpr = true;
struct A {};
struct B;
struct C :
std::conditional<myExpr,
A,
B>::type
{}; // Compilation error: B is declared but not defined
struct D :
enable_if_else<myExpr,
A,
B>::type
{}; // It works
谢谢
是否可以创建某种std :: enable_if_and_else,如std :: conditional,但对于未定义的类却没有编译时错误。
如果B
不完整,则std::conditional<true, A, B>::type
应该没有任何错误,因为您没有以要求B
完整的方式使用B
所以std::conditional
已经是您想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.