c++ 11从参数包创建静态数组
C++11 creating static array from a parameter pack
是否可以创建具有模板参数包值的static const
数组?我尝试了下面的代码,但是gcc 4.8.1给出了"错误:参数包未展开"
template<int... N>
struct ARRAY_OF_DIMS
{
static constexpr size_t NDIM = sizeof...(N);
static const int DIMS[NDIM];
};
template<int... N>
const int ARRAY_OF_DIMS<N>::DIMS[ARRAY_OF_DIMS<N>::NDIM] = { N... };
Try with:
template<int... N>
const int ARRAY_OF_DIMS<N...>::DIMS[ARRAY_OF_DIMS<N...>::NDIM] = { N... };
ARRAY_OF_DIMS<N>
中的参数pack为未扩容的参数。每个参数包如果不是sizeof...
的参数,则必须展开
相关文章:
- 如何使用类型级函数动态创建静态类型?
- QBS 为静态链路 MSVC 创建静态库
- 如何使用 GCC 编译器优化创建静态库?
- 创建静态哨兵节点的正确方法是什么
- 从现有项目(VS)创建静态库
- 从Excel/CSV值创建静态数组
- 在Xcode中创建静态库时,找不到libstdc .6.dylib
- 创建静态数据成员的代码有什么问题
- C 在不构造它的情况下创建静态对象(无需分配)
- C - 函数能够访问类方法,而不会创建静态或对象
- 使用新的位置来创建静态常量指针,指向静态内存缓冲区
- 编译libgdiplus源以创建静态链接的库,即libgdiplus.so
- 在C++中创建静态库(.a)(不适用于iOS)
- 需要帮助使用 make 创建静态 C++ 库
- g++正在创建静态库:无法读取符号.存档没有索引
- 如何为程序创建静态库
- C Gnu makefile我无法用ar创建静态库
- 竞争条件:一个线程创建静态对象,另一个线程在初始化完成之前使用它.如何处理
- 同时创建静态和动态库
- 如何使用系统库创建静态库