rexylib/include/rexy/traits.hpp

40 lines
1.1 KiB
C++

#ifndef REXY_TRAITS_HPP
#define REXY_TRAITS_HPP
#include <type_traits> //is_same, decay, integral_constant, declval
namespace rexy{
template<class T, class U>
struct is_type{
static std::true_type check(U*);
static std::false_type check(...);
static constexpr bool value = std::is_same<std::true_type,decltype(check(std::declval<std::decay_t<T>*>()))>::value;
};
template<class T, template<class...> class U>
struct is_template_type_helper{
static constexpr bool value = false;
};
template<template<class...> class U, class... Args>
struct is_template_type_helper<U<Args...>,U>{
static constexpr bool value = true;
};
template<class T, template<class...> class U>
struct is_template_type : public is_template_type_helper<std::decay_t<T>,U>{};
template<class T, template<class...> class Tmpl>
struct is_template_derived_type{
template<class... Args>
static std::true_type test(Tmpl<Args...>*);
static std::false_type test(void*);
static constexpr bool value = std::is_same<std::true_type,decltype(test(static_cast<std::decay_t<T>*>(nullptr)))>::value;
};
}
#endif