detection.h
Go to the documentation of this file.
#ifndef __utl_meta_detection_h__
#define __utl_meta_detection_h__
#include <utl/core/impl.h>
#include <utl/meta/operations.h>
#include <type_traits>
namespace utl {
namespace meta {
#if defined(UTL_WORKAROUND_CWG_1558)
template<typename... _Ts>
struct void_ {
using type = void;
};
template<typename... _Ts>
using void_t = eval<void_<_Ts...>>;
#else
template <typename...> using void_ = void;
template <typename...> using void_t = void;
#endif
struct nat_ {
nat_() = delete;
~nat_() = delete;
nat_(nat_ const&) = delete;
void operator = (nat_ const&) = delete;
};
namespace detail {
template <typename Default,
typename AlwaysVoid,
template<typename...> class Op, typename... Args>
struct detector {
using detected = false_;
using type = Default;
};
template <typename Default,
template<typename...> class Op, typename... Args>
struct detector <Default, void_t<Op<Args...>>, Op, Args...> {
using detected = true_;
using type = Op<Args...>;
};
template <typename Default,
template<typename...> class Op, typename... Args>
using detected_or = detector<Default, void, Op, Args...>;
} // namespace detail
template <template<typename...> class Op, typename... Args>
using is_detected = typename detail::detector<nat_, void, Op, Args...>::detected;
template< template<typename...> class Op, typename... Args>
constexpr bool is_detected_v = is_detected<Op, Args...>::value;
template <template<typename...> class Op, typename... Args>
using detected_t = eval <
detail::detector<nat_, void, Op, Args...>
>;
template <typename Default,
template<typename...> class Op, typename... Args>
using detected_or_t = eval <
detail::detected_or<Default, Op, Args...>
>;
template <typename Expected,
template<typename...> class Op, typename... Args >
using is_detected_exact = eval <
same_<Expected, detected_t<Op, Args...>>
>;
template <typename Expected,
template<typename...> class Op, typename... Args >
constexpr bool is_detected_exact_v = is_detected_exact< Expected, Op, Args...>::value;
template <typename To,
template<typename...> class Op, typename... Args >
using is_detected_convertible = eval <
std::is_convertible< detected_t<Op, Args...>, To >
>;
template <typename To,
template<typename...> class Op, typename... Args >
constexpr bool is_detected_convertible_v =
is_detected_convertible<To, Op, Args...>::value;
}}
#endif /* __utl_meta_detection_h__ */
utl::meta::void_t
void void_t
void_t type alias
Definition: detection.h:55
utl::meta::is_detected_exact_v
constexpr bool is_detected_exact_v
evaluates to true if evaluation of Op<Args...> is Expected and to false if not
Definition: detection.h:204
utl::meta::true_
bool_< true > true_
The type used as a compile-time boolean with true value.
Definition: integral.h:68
utl::meta::is_detected_convertible
eval< std::is_convertible< detected_t< Op, Args... >, To > > is_detected_convertible
Definition: detection.h:231
operations.h
Integral constant operations and logical operations.
utl::meta::void_
void void_
void_ type alias
Definition: detection.h:53
utl::meta::detail::detector< Default, void_t< Op< Args... > >, Op, Args... >::detected
true_ detected
Definition: detection.h:84
utl::meta::nat_
Definition: detection.h:63
utl::meta::detail::detector::type
Default type
Definition: detection.h:78
utl::meta::false_
bool_< false > false_
The type used as a compile-time boolean with false value.
Definition: integral.h:69
utl::meta::eval
typename Tp::type eval
Type alias for Tp::type. Used to evaluate/extract return type of metafunctions.
Definition: integral.h:49
utl::meta::is_detected_convertible_v
constexpr bool is_detected_convertible_v
Definition: detection.h:237
utl
STL&#39;s core language concepts.
Definition: _1wire.h:30
utl::meta::detected_t
eval< detail::detector< nat_, void, Op, Args... > > detected_t
Definition: detection.h:146
utl::meta::detail::detector< Default, void_t< Op< Args... > >, Op, Args... >::type
Op< Args... > type
Definition: detection.h:85
utl::meta::same_
Definition: operations.h:102
utl::meta::detail::detector::detected
false_ detected
Definition: detection.h:77
utl::meta::detail::detector
Definition: detection.h:76
utl::meta::is_detected_exact
eval< same_< Expected, detected_t< Op, Args... > > > is_detected_exact
Definition: detection.h:199
utl::meta::is_detected
typename detail::detector< nat_, void, Op, Args... >::detected is_detected
Definition: detection.h:118
utl::meta::is_detected_v
constexpr bool is_detected_v
Detection predicate.
Definition: detection.h:122
impl.h
Implementation detail main forward header.
utl::meta::detected_or_t
eval< detail::detected_or< Default, Op, Args... > > detected_or_t
Definition: detection.h:172