模板类的typedef? [英] typedefs for templated classes?

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

问题描述

有可能使用模板的 typedef 长类型吗?例如:

Is it possible to typedef long types that use templates? For example:

template <typename myfloat_t>
class LongClassName
{
    // ...
};

template <typename myfloat_t>
typedef std::vector< boost::shared_ptr< LongClassName<myfloat_t> > > LongCollection;

LongCollection<float> m_foo;

这不工作,但是有办法实现类似的效果吗?我只想避免键入和读取一个类型定义,几乎覆盖我的编辑器窗口的全部宽度。

This doesn't work, but is there a way to achieve a similar effect? I just want to avoid having to type and read a type definition that covers almost the full width of my editor window.

推荐答案

不,这是目前无法实现的。这将是可能在C + + 0X AFAIK。

No, that isn't possible currently. It will be made possible in C++0X AFAIK.

我能想到的最好的是

template<typename T> struct LongCollection {
    typedef std::vector< boost::shared_ptr< LongClassName<T> > > type;
};

LongCollection<float>::type m_foo;

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

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