- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
template < int ...Indices>
class T1 {
template <int _1, int _2>
class T2;
};
template <int ...Indices>
template <int _1>
class T1<Indices...>::T2<_1, sizeof...(Indices)> {};
//^--error: non-type template argument depends on a template parameter of the partial specialization
在 gcc 4.5+ 上编译,但在 clang 3.1 和 icc 上都不编译,两者都提示 sizeof...(Indices)
的使用。它只是后者编译器中尚未实现的功能还是某些特殊情况?
谢谢,
布特
最佳答案
标准在 [temp.class.spec] 第 8 段中说
Within the argument list of a class template partial specialization, the following restrictions apply:
— A partially specialized non-type argument expression shall not involve a template parameter of the partial specialization except when the argument expression is a simple identifier. [ Example:template <int I, int J> struct A {}; template <int I> struct A<I+5, I*2> {}; // error— end example ]
template <int I, int J> struct B {}; template <int I> struct B<I, I> {}; // OK
该规则的目的是禁止基于像示例中那样的非平凡表达式的偏特化,sizeof...(Indices)
不是简单的标识符,所以也许 clang 和 ICC 拒绝它是正确的。老实说,我不确定哪个编译器是正确的。我建议向其中一个编译器报告一个错误,如果他们说他们的实现是正确的,请将其报告给其他人以进行不同的解释!
关于c++ - 嵌套模板特化取决于封闭的模板参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8866881/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 4 年前。
正如您在 this travis.yml 中看到的那样文件,我的代码依赖于一些第三方库,我在构建项目之前将它们安装在远程系统上。 Travis 每次推送提交时都会下载并构建这些库,这可以避免吗?我的意
我是一名优秀的程序员,十分优秀!