首页 \ 问答 \ 嵌套的模板可能性(Nested template possibilities)

嵌套的模板可能性(Nested template possibilities)

以下有效吗?:

template<typename T> class C { C1<C2<T>> someMember; };

Is the following valid?:

template<typename T> class C { C1<C2<T>> someMember; };
更新时间:2023-03-21 14:03

最满意答案

那么,你需要对这个类型做些什么,或者使它成为typedef或成员,但是:

template <typename T>
struct C1 {};

template <typename T>
struct C2 {};

template <typename T>
struct C
{
    typedef C1<C2T> > type; // note the space!
};

>>实际上是右移操作符,所以你需要有一个空间让它正常工作。 但是,在C ++ 0x中,只需键入>> ; 它被解析得很好。*

*一些宽松的编译器目前会接受它。


Well, you'd need to do something with the type, either make it a typedef or member, but yes:

template <typename T>
struct C1 {};

template <typename T>
struct C2 {};

template <typename T>
struct C
{
    typedef C1<C2T> > type; // note the space!
};

>> is actually the right shift operator, so you need a space in there for it to work correctly. In C++0x, however, you can just type >>; it is parsed just fine.*

*Some lenient compilers will currently accept it.

相关问答

更多
  • 那令人困惑,你创建一个独特的quote_id, created_at列表,你做MAX(created_at)加上DISTINCT ON (quote_id) ? 这应该返回相同的结果: SELECT quote_id, MAX(created_at) AS max_created_at FROM billing_pricequotestatus GROUP BY quote_id That's confusing, you create a distinct list of quote_id, c ...
  • 从动态规划答案开始,您可以使用递归解决方案,然后使用记忆来缓存结果,自上而下的方法与Amit的自下而上相反。 vector subsetSum(vector& nums) { vector ans; generateSubsetSum(ans,0,nums,0); return ans; } void generateSubsetSum(vector& ans, int sum, vector& nums, int i) { ...
  • 许多if s的规范Python替换是字典: from functools import partial def function(var1, var2, var3): choices = {(True, True, True): partial(foo, bar), (True, True, False): partial(bar, foo), ...} choices[tuple(map(bool, (var1, var2, v ...
  • 我很困惑,为什么你不能这样做: for(int i = 0; i < 10000; i++) { Console.WriteLine(i.ToString("0000")); } I'm confused, why can't you just do this: for(int i = 0; i < 10000; i++) { Console.WriteLine(i.ToString("0000")); }
  • 没有“正确的方法”来处理这个问题,但是你可以做的一件事就是使用映射。 例: form_mappings = { 'US': USLocationForm, 'GB': GBLocationForm, #... } def enter_location(request): country = request.session['country'] country_form = form_mappings.get(country, OtherLocationForm) ...
  • 我是Sitecore的新手,但现在已经和Ionic合作了几年。 根据Sitecore网站上Lars Nielsen(Sitecore的CDO)撰写的文章: https://community.sitecore.net/general/blogs/business_blogs/b/technical_trends/posts/sitecore-as-a-true-headless-cms 它是一个完全无头的CMS,您可以执行从登录/注销到根据文档通过API检索和发布项目的所有内容: https://doc.s ...
  • 如果不使用私有(未记录的)API,您可能无法实现的目标 。 希望Apple能提供这种功能(与用户相关)虽然我不认为这很快就会发生。 如果你想进一步研究这个话题,首先要检查的是iphone-wireless - Stumbler的主页,它显示了MobileApple80211一个很好的用法。 What you're trying to do is sadly not possible without the usage of private (undocumented) API-s. Hopefully Ap ...
  • 那么,你需要对这个类型做些什么,或者使它成为typedef或成员,但是: template struct C1 {}; template struct C2 {}; template struct C { typedef C1 > type; // note the space! }; >>实际上是右移操作符,所以你需要有一个空间让它正常工作。 但是,在C ++ 0x中,只需键入>> ; 它被解析得很好。* ...
  • 不,smartctl不能那样做。 如果您想知道真正的物理磁盘大小,则应使用hdparm -N 。 No, smartctl cannot do that. If you want to know true physical disk size, you should use hdparm -N.
  • 没有什么似乎有任何错误,但根据您的描述,有一件事你可以尝试。 您可能会发现浏览器正在“错误地”解释您的自定义HTML标记,并且无法识别它们已被关闭。 如果是这种情况,那么你只会看到一个,因为其他的被包含在第一个div ,因此被替换。 请尝试将标记更改为以下内容:
    看看是否有效 Well nothing there seems to be wrong, ...

相关文章

更多

最新问答

更多
  • 在javascript中创建类以创建对象并在Java中创建类和对象之间的区别(Difference between creating a class in javascript to create an object and creating an class and object in Java)
  • Facebook API:将身份验证详细信息从Javascript SDK发送到PHP SDK(Facebook API: Send authentication detail from Javascript SDK to PHP SDK)
  • 如何停止队列动画jquery?(How can I stop queue animation jquery?)
  • 使用C#的井字游戏中的人工智能(Artificial Intelligence in Tic-Tac-Toe using C#)
  • 多少流量可以共享虚拟主机(对于Python Django站点)支持?(How Much Traffic Can Shared Web Hosting (for a Python Django site) support?)
  • 带有CIFilters的CAShapeLayer(CAShapeLayer with CIFilters)
  • 如何在Angular 2中读取JSON #text(How to read in Angular 2 the JSON #text)
  • 如何在xml中读取自闭标签的属性?(How to read self closing tag's attribute in xml?)
  • 无法使用http put将图像上传到亚马逊S3(Cannot upload image to amazon s3 using http put)
  • 文件结束无限循环(end of file infinite while-loop)
  • 在cpp的模板(template in cpp)
  • 在构建库时,clang和clang ++有什么区别?(What's the difference between clang and clang++ when building a library?)
  • ng类中的表达式(expression inside ng-class)
  • 在PHP中获取随机布尔值true / false(Get random boolean true/false in PHP)
  • 管道的高效分块用于严格的字节串(Efficient chunking of conduit for strict bytestring)
  • Python ternary_operator(如果其他标志做了其他操作,则执行其他操作)(Python ternary_operator (do-somthing if flag else do-another))
  • Sencha Touch面具发布(Sencha Touch mask ondisclosure)
  • 验证脚本上的通知[重复](Notices on validation script [duplicate])
  • 朋友功能(friend function)
  • 基于角坐标平移和变换平面几何(Translate and transform plane geometry based on corner coordinates)
  • Rails:'如果在本地运行'条件javascript标记包括(Rails: 'if running locally' conditional javascript tag include)
  • 解压文件(Unzipping files)
  • 使用ui-router以角度加载变量状态(loading in variable states with ui-router in angular)
  • 创建Azure云服务需要多长时间?(how long does it take to create an Azure Cloud Service? How to view log information?)
  • 指向整数的指针数组(Array of pointers to integers)
  • Laravel服务提供商没有看到我的包的主要类(Laravel service provider does not see the main class of my package)
  • 这个关于VSS / RSS / PSS / USS的解释是否准确?(Is this explanation about VSS/RSS/PSS/USS accurate?)
  • 在Django-Admin中通过row-id排序显示项目(Ordering the display items by row-id in Django-Admin)
  • 如何使用cythonize启用`--embed`?(How to enable `--embed` with cythonize?)
  • 用于将文本多行设置的Excel脚本(Excel script for ereasing text multiple rows)