c ++ / boost:在子类化时使用元组ctors

时间:2010-06-10 13:29:48

标签: c++ boost constructor initialization tuples

有没有办法使用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。

1 个答案:

答案 0 :(得分:2)

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

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

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