相关疑难解决方法(0)

为什么不能在带有模板的派生类中使用基类的别名?

考虑以下C ++代码:

template<typename Session>
class Step
{
public:
   using Session_ptr = boost::shared_ptr<Session>;
protected:
   Session_ptr m_session;
public:
   inline Step(Session_ptr session) : 
      m_session(session)
   {}

};

template<typename Socket>
class Session
{
public:
   Socket a;

   Session(Socket _a):
      a(_a)
   {}
};

template <typename Socket>
class StartSession : public Step<Session<Socket> >
{
protected:
   Session_ptr m_session; //Unknown type Session_ptr
public:
   inline StartSession(Session_ptr session) :
      Step<Session<Socket> >(session)
   {}

   void operator()(const boost::system::error_code& ec);
};

template <typename Socket>
class StartSession2 : public Step<Session<Socket> >
{
protected:
   typename Step<Session<Socket> >::Session_ptr m_session; …
Run Code Online (Sandbox Code Playgroud)

c++ templates c++11 type-alias

3
推荐指数
1
解决办法
1263
查看次数

标签 统计

c++ ×1

c++11 ×1

templates ×1

type-alias ×1