代码之家  ›  专栏  ›  技术社区  ›  puchu

全局范围内的typedef模板

  •  0
  • puchu  · 技术社区  · 16 年前

    使用模板类,我通常生成一些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 ...
    
    2 回复  |  直到 16 年前
        1
  •  3
  •   David Rodríguez - dribeas    16 年前

    我明白你的意思是写一个模板 typedef 这将创建第二个模板,其中第一个模板的某些参数已修复。如果是这个问题,不,不在现行标准中。在即将到来的c++0x标准中,您将能够:

    template <typename A, typename B> a_template;
    template <typename T>
    using other_template = a_template<T, int>;
    
        2
  •  1
  •   Cheers and hth. - Alf    16 年前

    不在C++ 98中。C++ 0x将支持这个。不过,我不能确切地回忆C++ 0x语法。

    干杯。,