c++ - How to make std::get to be member method(s)? -
std::get
link gets elements of tuple. overloaded function has number of versions. if have class derived tuple, , want introduce member method get() tuple elements using std::get. need write member method each version of std::get or can write one?
template<class... args> class data : public std::tuple<args...> { public: typedef std::tuple<args...> tuplety; // 1 version. template<unsigned n> (typename std::tuple_element<n, tuplety>::type)& get() { return std::get<n>(*this); } };
Comments
Post a Comment