我可以专门化类模板与别名模板吗? [英] Can I specialize a class template with an alias template?

查看:76
本文介绍了我可以专门化类模板与别名模板吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有一个简单的例子:

Here's a simple example:

class bar {};

template <typename>
class foo {};

template <>
using foo<int> = bar;

这是否允许?

推荐答案

$ clang++ -std=c++0x test.cpp
test.cpp:6:1: error: explicit specialization of alias templates is not permitted
template <>
^~~~~~~~~~~
1 error generated.

参考:14.1 [temp.decls] / p3:

Reference: 14.1 [temp.decls]/p3:


3因为别名声明不能声明模板id,所以不能
部分或明确地专门化别名模板。

3 Because an alias-declaration cannot declare a template-id, it is not possible to partially or explicitly specialize an alias template.

这篇关于我可以专门化类模板与别名模板吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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