首页 新闻 会员 周边 捐助

c++模板示例 template<class T, T::type n = 0> 第二个参数报语法错误,是示例有问题,还是说有其它方法可以屏蔽报错?

0
悬赏园豆:10 [已关闭问题] 浏览: 150次 解决于 2023-07-25 20:46

示例来自与cppreference.com,代码如下:

template<class T, T::type n = 0>
class X;
 
struct S
{
    using type = int;
};
 
using T1 = X<S, int, int>; // error: too many arguments
using T2 = X<>;            // error: no default argument for first template parameter
using T3 = X<1>;           // error: value 1 does not match type-parameter
using T4 = X<int>;         // error: substitution failure for second template parameter
using T5 = X<S>;           // OK

第一行 T::type 直接报语法错误,网上也没找到与这个示例类似的说明

C++
二次元攻城狮的主页 二次元攻城狮 | 菜鸟二级 | 园豆:462
提问于:2022-08-15 16:49
< > 人人可用的开源BI工具
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册
Top