std::experimental::is_detected,std::experimental::detected_t,std::experimental::detected_or (3) - Linux Manuals
std::experimental::is_detected,std::experimental::detected_t,std::experimental::detected_or: std::experimental::is_detected,std::experimental::detected_t,std::experimental::detected_or
NAME
std::experimental::is_detected,std::experimental::detected_t,std::experimental::detected_or - std::experimental::is_detected,std::experimental::detected_t,std::experimental::detected_or
Synopsis
Defined in header <experimental/type_traits>
template< template<class...> class Op, class... Args > (library fundamentals TS v2)
using is_detected = /* see below */;
template< template<class...> class Op, class... Args > (library fundamentals TS v2)
using detected_t = /* see below */;
template< class Default, template<class...> class Op, class... Args > (library fundamentals TS v2)
using detected_or = /* see below */;
The alias template detected_or is an alias for an unspecified class type with two public member typedefs value_t and type, which are defined as follows:
* If the template-id Op<Args...> denotes a valid type, then value_t is an alias for std::true_type, and type is an alias for Op<Args...>;
* Otherwise, value_t is an alias for std::false_type and type is an alias for Default.
The alias template is_detected is equivalent to typename detected_or<std::experimental::nonesuch, Op, Args...>::value_t. It is an alias for std::true_type if the template-id Op<Args...> denotes a valid type; otherwise it is an alias for std::false_type.
The alias template detected_t is equivalent to typename detected_or<std::experimental::nonesuch, Op, Args...>::type. It is an alias for Op<Args...> if that template-id denotes a valid type; otherwise it is an alias for the class std::experimental::nonesuch.
Additional utilities
template< template<class...> class Op, class... Args > (library fundamentals TS v2)
constexpr bool is_detected_v = is_detected<Op, Args...>::value;
template< class Default, template<class...> class Op, class... Args > (library fundamentals TS v2)
using detected_or_t = typename detected_or<Default, Op, Args...>::type;
template <class Expected, template<class...> class Op, class... Args> (library fundamentals TS v2)
using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
template <class Expected, template<class...> class Op, class... Args> (library fundamentals TS v2)
constexpr bool is_detected_exact_v = is_detected_exact<Expected, Op, Args...>::value;
template <class To, template<class...> class Op, class... Args> (library fundamentals TS v2)
using is_detected_convertible = std::is_convertible<detected_t<Op, Args...>, To>;
template <class To, template<class...> class Op, class... Args> (library fundamentals TS v2)
constexpr bool is_detected_convertible_v = is_detected_convertible<To, Op, Args...>::value;
The alias template is_detected_exact checks whether detected_t<Op, Args...> is Expected.
The alias template is_detected_convertible checks whether detected_t<Op, Args...> is convertible to To.
Possible implementation
Example
// Run this code