samedi 4 février 2023

tuple with get but U is a derived class of a tuple type

Suppose we have std::tuple<Ts*...> tuple;. One of the types is T* and a class U derives from T (polymorphically). How do we define

template <typename U> T* get(const std::tuple<Ts*...>&);

so that get<U>(tuple) returns std::get<T*>(tuple)? Of course, we want get<T>(tuple) to return std::get<T*>(tuple).

Aucun commentaire:

Enregistrer un commentaire