Skip to content
Snippets Groups Projects
Commit 386b88ab authored by Jan Trávníček's avatar Jan Trávníček
Browse files

add trait to match cv, and ref qualifiers

parent 63dad1c5
No related branches found
No related tags found
No related merge requests found
......@@ -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_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment