vendredi 18 octobre 2019

How can I change the values of objects in tuple?

In my class, I have a tuple object which I want to access the objects of in that as reference.

Actually, I want to know how can I write a get function to access the objects in my tuple?

I wrote a function which return the lvalue of my object in the tuple. I want to know how can I change it to return rvalue?

I have a template named GetIndex, which returns the index of type object in my tuple. In my tuple I definitely sure there are unique types object.

//return just lvalue
template <typename T>
T get_module()
{
  return std::get<Private::GetIndex<T, Args...>::value>(types);
}

//compilation error
template <typename T>
T& get_module()
{
  return &std::get<Private::GetIndex<T, Args...>::value>(types);
}
'''


Aucun commentaire:

Enregistrer un commentaire