While
var->atr
is a shortcut for
(*var).atr
Is there a shortcut for
(*var)->atr
which is the same as
(*(*var)).atr
(**var).atr
Perhaps something like a longer arrow?
var-->.atr
While
var->atr
is a shortcut for
(*var).atr
Is there a shortcut for
(*var)->atr
which is the same as
(*(*var)).atr
(**var).atr
Perhaps something like a longer arrow?
var-->.atr
No, there is no shortcut for two levels of indirection. We have to do either (**var).atr
, or (*var)->atr
.
If you really have a lot of levels of indirection, you may use a function template:
template <std::size_t N, typename T>
constexpr decltype(auto) deref(T&& t)
{
if constexpr (N == 0) {
return std::forward<T>(t);
} else {
return *deref<N - 1>(std::forward<T>(t));
}
}
so that deref<10>(x).member
means (**********x).member
. I won't recommend this though.