diff --git a/include/tao/pq/parameter_traits_aggregate.hpp b/include/tao/pq/parameter_traits_aggregate.hpp index f381696..034a584 100644 --- a/include/tao/pq/parameter_traits_aggregate.hpp +++ b/include/tao/pq/parameter_traits_aggregate.hpp @@ -27,7 +27,8 @@ namespace tao::pq } // namespace internal template< typename T > - struct parameter_traits< T, std::enable_if_t< is_aggregate_parameter< T > > > + requires is_aggregate_parameter< T > + struct parameter_traits< T > : private internal::parameter_tie_aggregate< T >, public parameter_traits< typename internal::parameter_tie_aggregate< T >::result_t > { diff --git a/include/tao/pq/result_traits.hpp b/include/tao/pq/result_traits.hpp index d95a055..12b6b43 100644 --- a/include/tao/pq/result_traits.hpp +++ b/include/tao/pq/result_traits.hpp @@ -33,9 +33,6 @@ namespace tao::pq template< typename T > inline constexpr std::size_t result_traits_size< T, decltype( result_traits< T >::size ) > = result_traits< T >::size; - template< typename T > - concept result_traits_has_null = requires( T t ) { result_traits< T >::null(); }; - template<> struct result_traits< const char* > { diff --git a/include/tao/pq/result_traits_aggregate.hpp b/include/tao/pq/result_traits_aggregate.hpp index 2723457..b177d01 100644 --- a/include/tao/pq/result_traits_aggregate.hpp +++ b/include/tao/pq/result_traits_aggregate.hpp @@ -46,7 +46,8 @@ namespace tao::pq } // namespace internal template< typename T > - struct result_traits< T, std::enable_if_t< is_aggregate_result< T > > > + requires is_aggregate_result< T > + struct result_traits< T > : internal::aggregate_result< T > {}; diff --git a/include/tao/pq/result_traits_array.hpp b/include/tao/pq/result_traits_array.hpp index 34aa4d9..80603d1 100644 --- a/include/tao/pq/result_traits_array.hpp +++ b/include/tao/pq/result_traits_array.hpp @@ -82,7 +82,7 @@ namespace tao::pq if( const auto* end = std::strpbrk( value, ",;}" ) ) { std::string input( value, end ); if( input == "NULL" ) { - if constexpr( result_traits_has_null< value_type > ) { + if constexpr( requires { result_traits< value_type >::null(); } ) { container.push_back( result_traits< value_type >::null() ); } else { @@ -124,7 +124,8 @@ namespace tao::pq } // namespace internal template< typename T > - struct result_traits< T, std::enable_if_t< is_array_result< T > > > + requires is_array_result< T > + struct result_traits< T > { static auto from( const char* value ) -> T { diff --git a/include/tao/pq/result_traits_tuple.hpp b/include/tao/pq/result_traits_tuple.hpp index 94b7e81..eb930d7 100644 --- a/include/tao/pq/result_traits_tuple.hpp +++ b/include/tao/pq/result_traits_tuple.hpp @@ -18,8 +18,9 @@ struct tao::pq::result_traits< std::tuple< T > > static constexpr std::size_t size = result_traits_size< T >; template< typename U = T > + requires std::is_same_v< T, U > && requires { result_traits< T >::null(); } [[nodiscard]] static auto null() - -> std::enable_if_t< std::is_same_v< T, U > && result_traits_has_null< T >, std::tuple< T > > + -> std::tuple< T > { return std::tuple< T >( result_traits< T >::null() ); } diff --git a/include/tao/pq/row.hpp b/include/tao/pq/row.hpp index f30dfb2..d8b3840 100644 --- a/include/tao/pq/row.hpp +++ b/include/tao/pq/row.hpp @@ -221,7 +221,7 @@ namespace tao::pq TAO_PQ_UNREACHABLE; // LCOV_EXCL_LINE } else if constexpr( ( result_traits_size< T > == 1 ) && !is_aggregate_result< T > ) { - if constexpr( result_traits_has_null< T > ) { + if constexpr( requires { result_traits< T >::null(); } ) { if( is_null( column ) ) { return result_traits< T >::null(); } diff --git a/include/tao/pq/table_row.hpp b/include/tao/pq/table_row.hpp index d34b104..10883ab 100644 --- a/include/tao/pq/table_row.hpp +++ b/include/tao/pq/table_row.hpp @@ -213,7 +213,7 @@ namespace tao::pq else if constexpr( result_traits_size< T > == 1 ) { const char* const value = get( column ); if( value == nullptr ) { - if constexpr( result_traits_has_null< T > ) { + if constexpr( requires { result_traits< T >::null(); } ) { return result_traits< T >::null(); } else {