【问题标题】:typedef templates in global scope全局范围内的 typedef 模板
【发布时间】:2010-10-13 17:25:33
【问题描述】:

使用模板类我通常会做一些 typedef 喜欢:

typedef super<puper<complex<template<type> > > > simple_name

我通常有两种方式:

template <class A, ...>
struct Types {
    typedef ...
}

template <class A, ...>
class Part_Of_Logick {
    public:
        typedef ...
}

是否可以在全局范围内设置 typedef? 像这样:

template <class A, ...>
typedef ...

【问题讨论】:

    标签: c++ templates scope typedef


    【解决方案1】:

    我理解您的意思是编写一个模板化的typedef,它将创建第二个模板,其中固定了第一个模板的一些参数。如果这是问题,不,不在当前标准中。在即将发布的 c++0x 标准中,您将能够:

    template <typename A, typename B> a_template;
    template <typename T>
    using other_template = a_template<T, int>;
    

    【讨论】:

      【解决方案2】:

      在 C++98 中没有。 C++0x 将支持这一点。不过,我记不清 C++0x 的语法了。

      干杯,

      --阿尔夫

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-05-03
        • 2016-11-06
        • 2017-05-22
        • 1970-01-01
        • 1970-01-01
        • 2017-03-05
        • 2011-06-07
        • 2017-01-20
        相关资源
        最近更新 更多