Как лучше определить std::conditional_t?
https://en.cppreference.com/w/cpp/types/conditional
Почему std::conditional_t определён как
template<bool B, class T, class F>
struct conditional { using type = T; };
template<class T, class F>
struct conditional<false, T, F> { using type = F; };
template< bool B, class T, class F >
using conditional_t = typename conditional<B,T,F>::type;
а не как:
template<bool B>
struct conditional {
template<class T, class F> using f = T;
};
template<>
struct conditional<false> {
template<class T, class F> using f = F;
};
template<bool B, class T, class F>
using conditional_t = typename conditional<B>::template f<T, F>;
, ведь последнее эффективней?
Источник: Stack Overflow на русском