I am developing some tuple structure, and I would like to allow the user to use its elements as fields,
DEVELOPMENT:
this is my tuple:
template<typename ...Ts>
struct myTuple{
std::tuple<Ts...> data;
template<size_t I>
inline type<I>& get_t() {
return std::get<I>(data);
}
};
At the moment, the user can have it as follows:
struct UserStruct{
myTuple<int,bool,string> t;
}
and use it like
UserStruct ob;
ob.t.get_t<0>() = 0;
It's a little trickier ... So I did it like that.
struct UserStruct{
myTuple<int,bool,string> t;
decltype(mo.get_t<0>()) myInt() {
return mo.get_t<0>();
}
decltype(t.get_t<1>()) myChar() {
return t.get_t<1>();
}
decltype(t.get_t<2>()) myString() {
return t.get_t<2>();
}
};
so that he can use it directly: myInt () = 0;
My goal is that he could use the tuple as if he had int, bool, stringdata elements without storing the link, which means I need a function (or functor) to get the link, so my solution is good, but the user needs to define the functions. (And the getter looks a lot worse in real code)
So, I would like something like this:
struct UserStruct{
myTuple<int,bool,string> t;
MyFunctor<0> myInt;
MyFunctor<1> myChar;
MyFunctor<2> myString;
};