diff --git a/include/sqlpp11/detail/void.h b/include/sqlpp11/detail/void.h index 530ee368..10d48199 100644 --- a/include/sqlpp11/detail/void.h +++ b/include/sqlpp11/detail/void.h @@ -31,14 +31,14 @@ namespace sqlpp { namespace detail { - template - struct void_impl - { - using type = void; - }; + template + struct void_impl + { + using type = void; + }; - template - using void_t = typename void_impl::type; + template + using void_t = typename void_impl::type; } } diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index 33b85839..f0a7598f 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -33,10 +33,60 @@ #include #include #include +#include #include namespace sqlpp { + namespace detail + { + template + struct value_type_of_impl + { + static_assert(wrong_t::value, "Attempting to optain value type from type without value_type"); + }; + + template + struct value_type_of_impl> + { + using type = typename T::_traits::_value_type; + }; + } + template + using value_type_of = typename detail::value_type_of_impl::type; + + // data types + struct boolean; + template + using is_boolean_t = std::is_same, boolean>; + + struct day_point; + template + using is_day_point_t = std::is_same, day_point>; + + struct floating_point; + template + using is_floating_point_t = std::is_same, floating_point>; + + struct integral; + template + using is_integral_t = std::is_same, integral>; + + struct text; + template + using is_text_t = std::is_same, text>; + + struct time_point; + template + using is_time_point_t = std::is_same, time_point>; + + // joined data type + template + using is_numeric_t = logic::any_t::value, is_floating_point_t::value>; + + template + using is_day_or_time_point_t = logic::any_t::value, is_time_point_t::value>; + namespace tag { struct can_be_null @@ -62,45 +112,10 @@ namespace sqlpp template using column_spec_can_be_null_t = typename detail::column_spec_can_be_null_impl::type; -#define SQLPP_VALUE_TYPE_GENERATOR(name) \ - struct name; \ - namespace detail \ - { \ - template \ - struct is_##name##_impl \ - { \ - using type = std::false_type; \ - }; \ - template \ - struct is_##name##_impl< \ - T, \ - typename std::enable_if::value>::type> \ - { \ - using type = std::true_type; \ - }; \ - } \ - template \ - using is_##name##_t = typename detail::is_##name##_impl::type; - - SQLPP_VALUE_TYPE_GENERATOR(boolean) - SQLPP_VALUE_TYPE_GENERATOR(day_point) - SQLPP_VALUE_TYPE_GENERATOR(time_point) - SQLPP_VALUE_TYPE_GENERATOR(integral) - SQLPP_VALUE_TYPE_GENERATOR(floating_point) - template - using is_numeric_t = logic::any_t::value, is_floating_point_t::value>; - - template - using is_day_or_time_point_t = logic::any_t::value, is_time_point_t::value>; - - SQLPP_VALUE_TYPE_GENERATOR(text) - #define SQLPP_VALUE_TRAIT_GENERATOR(name) \ namespace tag \ { \ - struct name \ - { \ - }; \ + struct name; \ } \ namespace detail \ { \ @@ -187,9 +202,6 @@ namespace sqlpp using is_database = typename std::conditional::value, std::false_type, std::true_type>::type; - template - using value_type_of = typename T::_traits::_value_type; - template using cpp_value_type_of = typename value_type_of::_cpp_value_type;