Using declaration for type-dependent template name

后端 未结 1 1116
清酒与你
清酒与你 2021-02-19 08:21

When CRTP is used inside a template, (or generally when a template parameter is passed as a base class template argument), is it impossible to name the base\'s member templates

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-19 08:51

    The following works fine with C++11:

    #include 
    
    template< typename d >
    struct base {
        template< typename >
        struct ct {};
    
        template< typename >
        void ft() {std::cerr << "cheesecake" << std::endl;}
    };
    
    template< typename x >
    struct derived : base< derived< x > > {
      template
        using ct = typename derived::base::template ct; // new in C++11
      using derived::base::ft;
    };
    
    int main()
    {
      derived::ct c;
      derived a;
      a.ft();
    }
    

    If that is not what you wanted, can you please give an example of how you would want to use ct and ft?

    0 讨论(0)
提交回复
热议问题