c – 可变模板的部分专业化需要第一个非可变模板参数
发布时间:2020-12-16 05:43:32 所属栏目:百科 来源:网络整理
导读:以下代码 #include iostream#include utilitytemplatetypename F,typename... Tstruct Wrapper{ };templatetypename Tstruct is_wrapper : std::false_type {};templatetypename... Tstruct is_wrapperWrapperT... : std::true_type {};//templatetypename F
以下代码
#include <iostream> #include <utility> template<typename F,typename... T> struct Wrapper{ }; template<typename T> struct is_wrapper : std::false_type {}; template<typename... T> struct is_wrapper<Wrapper<T...>> : std::true_type {}; //template<typename F,typename... T> //struct is_wrapper<Wrapper<F,T...>> : std::true_type {}; int main() { Wrapper<int,double> w; std::cout << is_wrapper<decltype(w)>::value << std::endl; } 打印0.但是,如果一个取消了中间的两行打印1. 为什么不总是打印1?第二部分专业化是否也不应该涵盖这一情况,这显然仅仅是由第三(评论)部分专业化所涵盖? 解决方法
代码应该确实符合部分专业化;标准从来没有实际上不允许这样做,但编译器确实需要一段时间才能实现可变模板及其正确的扣除. GCC符合4.9.0,Clang为3.6. Clang的相关错误报告是
#22191(虽然我找不到GCC的).
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- reactor和proactor模式
- c# – 此代码是同步还是异步?
- ruby-on-rails – 推送到Heroku的Rails 3.1 Sqlite3错误
- 正则表达式(regular expression)简明教程
- Oracle公共云中的MySQL InnoDB集群
- 你能在C#里面写一段c代码吗?
- c# – AutoMapper.dll中出现’AutoMapper.AutoMapperMappin
- Using the Oracle ASM Cluster File System (Oracle ACFS)
- AJAX学习之序列一:JavaScript关键特征,你了解几个?
- ruby-on-rails – 如何处理轨道无限/无限过程