What is the standard conform syntax for template constructor inheritance?

前端 未结 1 1213
情书的邮戳
情书的邮戳 2021-02-05 23:10

GCC 4.8.1 accepts

template 
class Subclass : public Baseclass
{
public:
    using typename Baseclass::Baseclass;
};


        
相关标签:
1条回答
  • 2021-02-06 00:01

    The answer is a bit buried in the standard. A using declaration is defined as (7.3.3):

    using [typename] nested-name-specifier unqualified-id;
    

    The nested-name-specifier resolves after some steps into simple-template-id which is defined as

    template-name < [template-argument-list] >
    

    In short, the standard conforming syntax is

    template <typename T>
    class Subclass : public Baseclass<T>
    {
    public:
        using typename Baseclass<T>::Baseclass;
    };
    
    0 讨论(0)
提交回复
热议问题