在类的成员初始化列表中初始化std :: tuple

时间:2014-08-26 02:11:31

标签: c++ c++11

我有一个元组作为模板类的成员,我想在构造类的实例时初始化std::tuple

template <typename ...Type>
struct Boundary {
    std::tuple<Type...> lower_boundary, upper_boundary;
    Boundary() : lower_boundary(), upper_boudary(){}
}

对于lower_boundaryupper_boundary,我想将每个元素初始化为numeric_limits<type for that element>::min()max()。我有什么方法可以在成员初始化列表中做到这一点?我知道我可以在构造函数中设置它,我正在寻找其他方法。

1 个答案:

答案 0 :(得分:6)

例如,

Boundary()
    : lower_boundary(std::numeric_limits<Type>::min()...),
      upper_boundary(std::numeric_limits<Type>::max()...)
    {}
相关问题