detection
The “detection idiom” is a means to provide “detectors” (code from a using
type definition whose definition has an expression wrapped in decltype(...)
) that can tell if a given expression compiles.
-
template<typename _Default, typename _Void, template<typename...> typename _Op, typename ..._Args>
class detector A class to be used for the “detection idiom”. Provides
value_t
for the true_type/false_type dichotomy and providestype
for the detected type.Remark
This is more efficient and useful at the member declarations level, especially when needing to dispatch to functionality that may or may not exist in wrapped or base classes.
-
class nonesuch
A class specifically for the case where the detection idiom cannot detect the requirements.
-
using ztd::is_detected = typename detector<nonesuch, void, _Op, _Args...>::value_t
A commonly-used alias for getting a
true_type
orfalse_type
indicating whether the operation was successful.
-
template<template<typename...> typename _Op, typename ..._Args>
constexpr bool ztd::is_detected_v = is_detected<_Op, _Args...>::value A
_v
shortcut for ztd::is_detected.
-
using ztd::detected_t = typename detector<nonesuch, void, _Op, _Args...>::type
A
_t
shortcut for using the ztd::detector to provide either ztd::nonsuch or the given type as yielded by the operation applied to the arguments.
-
using ztd::detected_or = detector<_Default, void, _Op, _Args...>
A shortcut for using the ztd::detector to provide either
_Default
or the given type as yielded by the operation applied to the arguments.