c – SFINAE sizeof =检测表达式是否编译
发布时间:2020-12-16 07:51:24 所属栏目:百科 来源:网络整理
导读:我刚刚发现如何检查操作符被提供用于类型. templateclass T T lvalue_of_type();templateclass T T rvalue_of_type();templateclass Tstruct is_printable{ templateclass U static char test(char(*)[sizeof( lvalue_of_typestd::ostream() rvalue_of_typeU
我刚刚发现如何检查操作符<<被提供用于类型.
template<class T> T& lvalue_of_type(); template<class T> T rvalue_of_type(); template<class T> struct is_printable { template<class U> static char test(char(*)[sizeof( lvalue_of_type<std::ostream>() << rvalue_of_type<U>() )]); template<class U> static long test(...); enum { value = 1 == sizeof test<T>(0) }; typedef boost::integral_constant<bool,value> type; }; 这个技巧是否知名,还是刚刚获得了编程的诺贝尔奖? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – 运行’rails s’时的分段错误
- C语言判断语句if else switch语句实例讲解
- ios – reloadSections的麻烦:withRowAnimation动画
- c – 如何从32位代码启动64位的Windows进程?
- objective-c – Sprite Kit – iOS 7.1更新后由于比例而导致
- oracle – 从数据字典中查找包全局变量
- c# – LINQ查询可能无限的列表
- c – 算法和数据结构
- c# – Selenium 2 WebDriver – Chrome – 从通过JavaScrip
- Project Perfect让Swift在服务器端跑起来-引言(一)