"constexpr if"不支持别名使用?
"constexpr if" not support alias using?
>我使用 gcc7.1 编译代码,但出现一些编译错误:
错误:"if"之前应为非限定 ID
错误:"否则"之前应为非限定 ID
class Test
{
int a{1};
string b{"test"};
public:
template <int N> auto & get()
{
if constexpr (N==0)
return a;
else
return b;
}
};
namespace std {
template<> struct tuple_size<Test> { static const int value = 2; };
template<size_t N> struct tuple_element<N, Test>
{
if constexpr (N==0) //error: expected unqualified-id before ‘if’
using type = int;
else //error: expected unqualified-id before ‘else’
using type = string;
//using type = conditional_t<N==0, int, string>; //this works
};
}
constexpr if
语句仍然是if
语句,并且只能出现在可以使用if
语句的上下文中。
这不包括类(模板(定义。
相关文章:
- 为什么istream不支持右值提取
- 为什么std::isnan 不是 constexpr?
- 错误:(-210:不支持的格式或格式组合)功能'create'中的硬件视频解码器不支持视频源
- Casablanca/cpprestsdk listener.support接受函数,但不支持方法
- 为什么C++不支持对未初始化变量进行智能分析?
- 为什么reinterpret_cast不是 constexpr?
- 在 c++ 中连接字符串和整数,以便在 C++ 11 不支持计算机的情况下读取多个文件
- 在 Ubuntu 18.04 上编译 GLSL 着色器时"不支持 GLSL 3.30"?
- 为什么我的 constexpr 对象在我的函数中不是 constexpr?
- 为什么联机C++ IDE 不支持"graphics.h"头文件?
- Clang编译器不支持aarch64-apple-darwin上的-fxray-instrument
- 为什么我的 clang 格式不支持 PPDirectiveIndentStyle 选项?
- 比较两个 constexpr 指针不是 constexpr?
- 为什么某些 STL 容器(堆栈、队列、优先级队列)不支持迭代器?
- 为什么不支持 Xcode 1.5?
- C++20 从括号中的值列表初始化聚合,不支持内部数组
- 为什么结构化绑定不支持可变数组?
- 您选择的 CPU 不支持 x86-64 指令集
- "constexpr if"不支持别名使用?
- 静态constexpr成员似乎不支持std::min