【问题标题】:c++/boost: use tuple ctors when subclassingc++/boost:子类化时使用元组
【发布时间】:2010-06-10 13:29:48
【问题描述】:

有没有办法像这里一样使用 boost 元组的 ctors 作为子类方法(和 ctors)的补充?

// typedef boost::tuple<int, SomeId, SomeStatus> Conn;
// Conn(1); // works and initializes using default ctors of Some*
struct Conn : boost::tuple<int, AsynchId, AccDevRetStatus> {};
Conn(1); // "no matching function call" (but i want it so much)

T.H.X.

【问题讨论】:

    标签: c++ boost constructor initialization tuples


    【解决方案1】:

    您必须自己定义所有构造函数并转发给基类。

    请注意,您可以改为创建 typedef。

    typedef boost::tuple<int, AsynchId, AccDevRetStatus> Conn;
    

    【讨论】:

      猜你喜欢
      • 2016-01-26
      • 2021-11-06
      • 2017-07-13
      • 2010-12-06
      • 1970-01-01
      • 2012-12-13
      • 2017-11-03
      • 1970-01-01
      相关资源
      最近更新 更多