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
const
overload and the second one the non-const
one. That's because_t
isconst
in the first case and non-const
in the second one.Which one is used in the type alias depends on the type of
data
. Is itconst
? If so, theconst
overload is aliased. If not, the non-const
one is.To get a "virtual value" of any type, you can use
std::declval
. This code would alias theconst
version: