diff --git a/alib2std/src/extensions/type_traits.hpp b/alib2std/src/extensions/type_traits.hpp index c70b412e200c9899021206c32d596a87dcdf69bb..f44e22e44b8be6af7273710cb060d7bf0c3e1225 100644 --- a/alib2std/src/extensions/type_traits.hpp +++ b/alib2std/src/extensions/type_traits.hpp @@ -21,6 +21,8 @@ namespace std { static const bool value = sizeof(Yes) == sizeof(has_clone::test((typename std::remove_reference<T>::type*)0)); }; +// ---------------------------------------------------------------------------------------------------- + template <typename T> struct is_base_of<T, T> { static const bool value = true; @@ -41,6 +43,8 @@ namespace std { static const bool value = is_base_of<T, F>::value || is_base_of_any<T, Ts...>::value; }; +// ---------------------------------------------------------------------------------------------------- + template < size_t N, typename ... T > struct get_type_pack_element; @@ -54,6 +58,8 @@ namespace std { typedef typename get_type_pack_element < N - 1, Ts ... >::type type; }; +// ---------------------------------------------------------------------------------------------------- + template < typename T, typename ... Ts > struct is_in; @@ -66,6 +72,38 @@ namespace std { template < typename T, typename ... Ts > struct is_in < T, T, Ts ... > : std::true_type { }; +// ---------------------------------------------------------------------------------------------------- + + template < class Ref, class Type > + struct match_cv_ref_rec { + typedef Type type; + }; + + template < class Ref, class Type > + struct match_cv_ref_rec < const Ref, Type > { + typedef typename add_const < typename match_cv_ref_rec < Ref, Type >::type >::type type; + }; + + template < class Ref, class Type > + struct match_cv_ref_rec < Ref &, Type > { + typedef typename add_lvalue_reference < typename match_cv_ref_rec < Ref, Type >::type >::type type; + }; + + template < class Ref, class Type > + struct match_cv_ref_rec < Ref &&, Type > { + typedef typename add_rvalue_reference < typename match_cv_ref_rec < Ref, Type >::type >::type type; + }; + + template < class Ref, class Type > + struct match_cv_ref_rec < volatile Ref, Type > { + typedef typename add_volatile < typename match_cv_ref_rec < Ref, Type >::type >::type type; + }; + + template < class Ref, class Type > + struct match_cv_ref { + typedef typename match_cv_ref_rec < Ref, typename decay < Type >::type >::type type; + }; + } /* namespace std */ #endif /* __TYPE_TRAITS_HPP_ */