49 #ifndef LIB_META_TRAIT_H 50 #define LIB_META_TRAIT_H 56 #include <type_traits> 66 template<
class X,
class D>
class unique_ptr;
71 template<
class X,
class B>
class P;
89 using std::remove_cv_t;
90 using std::remove_pointer_t;
91 using std::remove_reference_t;
92 using std::conditional_t;
93 using std::is_reference_v;
94 using std::is_lvalue_reference_v;
95 using std::is_rvalue_reference_v;
96 using std::is_pointer;
97 using std::is_base_of;
98 using std::is_convertible;
99 using std::is_constructible;
100 using std::is_floating_point;
101 using std::is_arithmetic;
102 using std::is_unsigned;
103 using std::is_signed;
111 static constexpr
bool isConst_v = std::is_const_v<remove_reference_t<T>>;
113 static constexpr
bool isLRef_v = std::is_lvalue_reference_v<T>;
115 static constexpr
bool isRRef_v = std::is_rvalue_reference_v<T>;
117 static constexpr
bool isRef_v = std::is_reference_v<T>;
137 return const_cast<X&
> (x);
152 using Type = remove_cv_t<X>;
155 extract (
const X* ptr)
158 return const_cast<Type&
> (*ptr);
188 template<
typename X,
class D>
195 extract (std::unique_ptr<X,D>
const& ptr)
216 template<
typename X,
class B>
239 typename Unwrap<X>::Type&
252 using TypeUnconst = conditional_t<is_reference_v<X>
253 , conditional_t<is_rvalue_reference_v<X>
254 , remove_cv_t<remove_reference_t<X>> &&
255 , remove_cv_t<remove_reference_t<X>> & >
257 using TypeReferred = remove_reference_t<TypeUnconst>;
258 using TypePointee = remove_pointer_t<TypeReferred>;
259 using TypePlain = remove_cv_t<TypePointee>;
261 using Type =
typename Unwrap<TypePlain>::Type;
274 template<
typename TY>
279 typedef TY& Reference;
282 template<
typename TY>
286 typedef TY** Pointer;
287 typedef TY*& Reference;
290 template<
typename TY>
295 typedef TY& Reference;
298 template<
typename TY>
303 typedef TY& Reference;
315 template<
typename T,
typename U>
317 : is_same <typename Strip<T>::TypeReferred
318 ,typename Strip<U>::TypeReferred>
322 template<
typename S,
typename I>
324 : __or_< __and_< is_class<I>
333 template<
typename S,
typename I>
336 ,typename Strip<I>::TypeReferred>
340 template<
typename S,
typename G>
342 : std::is_convertible<typename RefTraits<S>::Reference
343 ,typename RefTraits<G>::Reference
350 : __or_< is_basically<X, std::string>
351 , is_basically<X, std::string_view>
352 , is_convertible<X, const char*>
374 : __or_< is_arithmetic<X>
381 : __and_<can_lexical2string<X>
382 ,__not_<can_convertToString<X>>
389 : is_same<X, std::basic_filebuf<char, std::char_traits<char> > >
395 : __and_<is_class<typename Strip<X>::TypePlain>
396 ,__not_<is_pointer<X>>
397 ,__not_<can_lexical2string<X>>
398 ,__not_<is_StreamSource<X>>
414 template <
typename T,
typename D>
424 template<
typename NUM>
426 : __and_<is_arithmetic<NUM>
427 ,__not_<is_floating_point<NUM>>
447 template<
typename SRC,
typename TAR>
449 : __or_<__and_<is_unsigned<SRC>, is_signed<TAR>>
450 ,__and_<is_signed<SRC>, is_unsigned<TAR>>
451 ,__and_<is_nonFloat<SRC>, is_floating_point<TAR>>
452 ,__and_<is_floating_point<SRC>, is_nonFloat<TAR>>
453 ,__not_<is_constructible<TAR, SRC>>
457 template<
typename TAR>
459 : __or_<is_arithmetic<TAR>
460 ,is_floating_point<TAR>
464 #define TRAIT_IS_NARROWING(_SRC_, _TAR_) \ 466 struct is_narrowingInit<_SRC_, _TAR_> \ 470 TRAIT_IS_NARROWING (int64_t, int32_t)
471 TRAIT_IS_NARROWING (int64_t, int16_t)
472 TRAIT_IS_NARROWING (int64_t, int8_t)
473 TRAIT_IS_NARROWING (int64_t,
char)
474 TRAIT_IS_NARROWING (int32_t, int16_t)
475 TRAIT_IS_NARROWING (int32_t, int8_t)
476 TRAIT_IS_NARROWING (int32_t,
char)
477 TRAIT_IS_NARROWING (int16_t, int8_t)
478 TRAIT_IS_NARROWING (int16_t,
short)
479 TRAIT_IS_NARROWING (int16_t,
char)
481 TRAIT_IS_NARROWING (uint64_t, uint32_t)
482 TRAIT_IS_NARROWING (uint64_t, uint16_t)
483 TRAIT_IS_NARROWING (uint64_t, uint8_t)
484 TRAIT_IS_NARROWING (uint32_t, uint16_t)
485 TRAIT_IS_NARROWING (uint32_t, uint8_t)
486 TRAIT_IS_NARROWING (uint16_t, uint8_t)
487 TRAIT_IS_NARROWING (uint16_t, ushort)
489 TRAIT_IS_NARROWING (
double,
float)
494 #undef TRAIT_IS_NARROWING 512 using Type =
typename Strip<T>::Type;
519 enum{ value = std::is_constructible<bool, Type>::value
520 and HasNested_value_type<Type>::value
521 and HasOperator_deref<Type>::value
522 and HasOperator_inc<Type>::value
536 using Type =
typename Strip<T>::Type;
543 enum{ value = HasArglessFun_checkPoint<Type>::value
544 and HasArglessFun_iterNext<Type>::value
545 and HasArglessFun_yield<Type>::value
557 using Type =
typename Strip<T>::Type;
565 enum { value = HasNested_iterator<Type>::value
566 and HasFunSig_begin<Type>::value
567 and HasFunSig_end<Type>::value
577 enum { value = HasNested_iterator<Type>::value
578 and HasFunSig_begin<Type>::value
579 and HasFunSig_end<Type>::value
589 enum { value = HasNested_const_iterator<Type>::value
590 and HasFunSig_begin<Type>::value
591 and HasFunSig_end<Type>::value
601 enum { value = HasNested_const_iterator<Type>::value
602 and HasFunSig_begin<Type>::value
603 and HasFunSig_end<Type>::value
609 enum { value = is_iterable::value
610 or is_const_iterable::value
611 or is_noexcept_iterable::value
612 or is_const_noexcept_iterable::value
621 using Type =
typename Strip<T>::Type;
629 enum { value = HasNested_reverse_iterator<Type>::value
630 and HasFunSig_rbegin<Type>::value
631 and HasFunSig_rend<Type>::value
641 enum { value = HasNested_reverse_iterator<Type>::value
642 and HasFunSig_rbegin<Type>::value
643 and HasFunSig_rend<Type>::value
653 enum { value = HasNested_const_reverse_iterator<Type>::value
654 and HasFunSig_rbegin<Type>::value
655 and HasFunSig_rend<Type>::value
665 enum { value = HasNested_const_reverse_iterator<Type>::value
666 and HasFunSig_rbegin<Type>::value
667 and HasFunSig_rend<Type>::value
673 enum { value = is_backIterable::value
674 or is_const_backIterable::value
675 or is_noexcept_backIterable::value
676 or is_const_noexcept_backIterable::value
A refcounting Handle to an MObject of type MO, used to constrain or explicitly specify the location w...
#define META_DETECT_OPERATOR_INC()
Detector for a prefix increment operator.
#define META_DETECT_FUNCTION(_RET_TYPE_, _FUN_NAME_, _ARGS_)
Detector for a specific member function.
Steam-Layer implementation namespace root.
Implementation namespace for support and library code.
#define META_DETECT_FUNCTION_ARGLESS(_FUN_)
Detector for an argument-less member function with the given name.
#define META_DETECT_OPERATOR_DEREF()
Detector for a dereferentiation operator.
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor...
Duration is the internal Lumiera time metric.
Unwrap< X >::Type & unwrap(X const &wrapped)
convenience shortcut: unwrapping free function.
#define META_DETECT_NESTED(_TYPE_)
Detector for a nested type.
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
basic constant internal time value.
Metaprogramming helpers to check for specific properties of a type in question.