I have the following overloaded function :
template<size_t N, typename T>
auto get(const T & _t) -> decltype(std::get<...>(_t)) {
...
}
template<size_t N, typename T>
auto get(T & _t) -> decltype(std::get<...>(_t)) {
...
}
First question is :
does the first one uses std::get(const tuple<_Elements...>& __t)
and the second one std::get(tuple<_Elements...>& __t) ??
now I want to alias the return type of my new function get :
using type = typename decltype(aux::get<I>(data))::type;
which one is used here ? the const or not ? and How can I choose ? I would like to alias both !! data is non-const
Yes, the first one uses the
constoverload and the second one the non-constone. That's because_tisconstin the first case and non-constin the second one.Which one is used in the type alias depends on the type of
data. Is itconst? If so, theconstoverload is aliased. If not, the non-constone is.To get a "virtual value" of any type, you can use
std::declval. This code would alias theconstversion: