forked from Alepha/Alepha
More concepts to drive comparisons.
This commit is contained in:
@ -110,20 +110,20 @@ namespace Alepha::Hydrogen
|
|||||||
return spaceship_lens( t );
|
return spaceship_lens( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T, typename= void >
|
|
||||||
struct supports_value_lens : std::false_type {};
|
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct supports_value_lens< T, std::void_t< decltype( value_lens( std::declval< const T & >() ) ) > > : std::true_type {};
|
concept ValueLensed=
|
||||||
|
Comparable< T >
|
||||||
template< typename T >
|
and
|
||||||
constexpr bool supports_value_lens_v= supports_value_lens< T >::value;
|
requires( const T &val )
|
||||||
|
{
|
||||||
|
{ value_lens( val ) } -> Concepts::Comparable;
|
||||||
|
};
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
constexpr decltype( auto )
|
constexpr decltype( auto )
|
||||||
make_value_lens( T &t )
|
make_value_lens( T &t )
|
||||||
{
|
{
|
||||||
if constexpr( supports_value_lens_v< T > ) return value_lens( t );
|
if constexpr( ValueLensed< T > ) return value_lens( t );
|
||||||
//else if constexpr( supports_default_lens_v< T > ) return default_lens( t );
|
//else if constexpr( supports_default_lens_v< T > ) return default_lens( t );
|
||||||
else static_assert( Meta::dep_value< false, T > );
|
else static_assert( Meta::dep_value< false, T > );
|
||||||
}
|
}
|
||||||
@ -140,19 +140,13 @@ namespace Alepha::Hydrogen
|
|||||||
};
|
};
|
||||||
|
|
||||||
constexpr decltype( auto )
|
constexpr decltype( auto )
|
||||||
equality_lens( MemberEqualityLensed auto &t )
|
equality_lens( const MemberEqualityLensed auto &t )
|
||||||
{
|
{
|
||||||
return t.equality_lens();
|
return t.equality_lens();
|
||||||
}
|
}
|
||||||
|
|
||||||
template
|
|
||||||
<
|
|
||||||
Comparable T,
|
|
||||||
typename= std::enable_if_t< supports_value_lens_v< T > >,
|
|
||||||
overload< __LINE__ > = nullptr
|
|
||||||
>
|
|
||||||
constexpr decltype( auto )
|
constexpr decltype( auto )
|
||||||
equality_lens( T &t )
|
equality_lens( const ValueLensed auto &t )
|
||||||
{
|
{
|
||||||
return value_lens( t );
|
return value_lens( t );
|
||||||
}
|
}
|
||||||
@ -198,14 +192,8 @@ namespace Alepha::Hydrogen
|
|||||||
return t.strict_weak_order_lens();
|
return t.strict_weak_order_lens();
|
||||||
}
|
}
|
||||||
|
|
||||||
template
|
|
||||||
<
|
|
||||||
Comparable T,
|
|
||||||
typename= std::enable_if_t< supports_value_lens_v< T > >,
|
|
||||||
overload< __LINE__ > = nullptr
|
|
||||||
>
|
|
||||||
constexpr decltype( auto )
|
constexpr decltype( auto )
|
||||||
strict_weak_order_lens( T &t )
|
strict_weak_order_lens( const ValueLensed auto &t )
|
||||||
{
|
{
|
||||||
return value_lens( t );
|
return value_lens( t );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user