向前声明模板别名 [英] forward declare a template alias

查看:117
本文介绍了向前声明模板别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个别名模板,用using指令定义:

  template< typename A& 
使用T = TC

C ++ 11提供了一种机制来转发声明此模板别名 T



我试过:

  template< typename> struct T; 

和:

  template< typename> 
使用T;

但都会返回编译器错误(与以前的声明冲突)。

解决方案

/ div>

不,这是不可能的。



你想要做的是forward declare TC 然后在其下面定义 T

  template< typename T,typename U> 
struct TC;

template< typename A>
,使用T = TC


I have an aliased template, defined with the using directive:

template<typename A>
using T=TC<decltype(A::b),decltype(A::c)>;

Does C++11 offer a mechanism to forward declare this template alias T?

I tried:

template<typename> struct T;

and:

template<typename>
using T;

but both return compiler errors ("conflict with previous declaration"). I am using gcc 4.8.

What is the syntax to get this to work?

解决方案

No, it's not possible.

What you want to do is forward declare TC, then define T immediately below it.

template<typename T, typename U>
struct TC;

template<typename A>
using T=TC<decltype(A::b),decltype(A::c)>;

这篇关于向前声明模板别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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