Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Nov 15, 2024
1 parent add6c78 commit b6fcda8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion include/tao/pq/parameter_traits_aggregate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 >
{
Expand Down
3 changes: 0 additions & 3 deletions include/tao/pq/result_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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* >
{
Expand Down
3 changes: 2 additions & 1 deletion include/tao/pq/result_traits_aggregate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 >
{};

Expand Down
5 changes: 3 additions & 2 deletions include/tao/pq/result_traits_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion include/tao/pq/result_traits_tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}
Expand Down
2 changes: 1 addition & 1 deletion include/tao/pq/row.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion include/tao/pq/table_row.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b6fcda8

Please sign in to comment.