模板中的模板:为什么">'应该是`> >在嵌套模板参数列表“ [英] Template within template: why "`>>' should be `> >' within a nested template argument list"

查看:405
本文介绍了模板中的模板:为什么">'应该是`> >在嵌套模板参数列表“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道当我们在另一个模板中使用模板时,我们应该这样写:



vector< pair< int,int> ; > s;



<$>

c $ c> vector< pair< int,int>>



在嵌套模板参数列表中应该是`>>'


我认为这是可以理解的,

解决方案

有时候你会想要 >它>> 。考虑

  boost :: array< int,1024>> 2> X; 

在C ++ 03中,这会成功解析并创建一个大小为 256的数组


I know that when we are using template inside another template, we should write it like this:

vector<pair<int,int> > s;

and if we write it without the whitespace:

vector<pair<int,int>> s;

we will get an error:

`>>' should be `> >' within a nested template argument list

I see this is understandable, but I just can't help but wondering, in which cases will this be really ambiguous?

解决方案

Sometimes you want it to be >>. Consider

boost::array<int, 1024>>2> x;

In C++03 this successfully parses and creates an array of size 256.

这篇关于模板中的模板:为什么&quot;&gt;'应该是`&gt; &gt;在嵌套模板参数列表“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆