Can I use it enable_ifwith typedef?
No, you can’t. std::enable_ifleaves the type undefined if the condition is false. Only if the condition is true is a member defined type;
template< bool B, class T = void >
struct enable_if;
If B- true, std::enable_ifhas the type publicped typedef equal to T; otherwise there is no typedef member.
typedef , . enable_if , SFINAE.
,
?
std::conditional. typedef (type) true false .
template< bool B, class T, class F >
struct conditional;
typedef , T, B - true F, B - false.
, :
typedef typename std::conditional<cond, int, double>::type Type;
;
using Type = std::conditional_t<cond, int, double>;