c – 使用类型别名如何指定依赖于模板参数的模板模板参数?
发布时间:2020-12-16 09:56:30 所属栏目:百科 来源:网络整理
导读:参见英文答案 Where and why do I have to put the “template” and “typename” keywords?????????????????????????????????????6个 最小的例子: templatetemplateclass ... classstruct templ {};templateclass Tusing special = templT::type;int main
参见英文答案 >
Where and why do I have to put the “template” and “typename” keywords?????????????????????????????????????6个
最小的例子: template<template<class ...> class> struct templ {}; template<class T> using special = templ<T::type>; int main() {} clang: test.cpp:5:23: error: template argument for template template parameter must be a class template or type alias template using special = templ<T::type>; 实际上,我的意思是说T :: type是一个类模板,例如 struct detail1 { template <class T> using type = std::vector<T>; }; struct detail2 { template <class T> struct type {}; }; 但是怎么能这么说呢? g建议使用typename T :: type,但这对我来说是错误的,事实上,这并不能解决错误. 解决方法
您需要指定该类型是模板:
template<class T> using special = templ< T::template type>; 这是必需的,因为T :: type依赖于模板参数T. 另见Where and why do I have to put the “template” and “typename” keywords? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – 了解rails路由:在route.rb中匹配vs根
- Oracle12C 单实例dataguard配置
- ruby-on-rails-3.1 – 不显示x轴标签的情节
- 在vb.net中循环遍历通用列表
- 如何在PostgreSQL中以编程方式查找继承的表?
- 一些基于React、Vue、Node.js、MongoDB技术栈的实践项目
- xml文件参照XSD时开始部分中的xmlns:和xsi:schemaLocation
- react-native 导航栏的传值、tabbarNavigation 如何隐藏tab
- Oracle merge into delete语法
- PostgreSQL如何将100多个参数传递给一个函数