Flexibility of template alias in C++0x

后端 未结 2 2156
夕颜
夕颜 2021-02-12 16:27

As I understand, template aliases in C++0x will allow us to do the following:

template 
using Dictionary = std::map< std::string, T >;

D         


        
2条回答
  •  后悔当初
    2021-02-12 17:13

    typename is required when a member type follows the :: operator and a template-id precedes it.

    The usage of typename you mention isn't specific to template aliases nor is it required unless you're aliasing to a member such as ::type, but that is a common use case.

    For example, there's no typename when introducing a simple alias name to an existing template.

    template< typename x >
    class bar;
    
    template< typename x >
    using foo = bar< x >; // no typename needed
    

提交回复
热议问题