1
0
forked from Alepha/Alepha

Conceptualize free strict_weak_order_lens.

This commit is contained in:
2025-08-28 00:31:18 -04:00
parent 0ba1ea988a
commit cb3079ca9e

View File

@ -172,20 +172,21 @@ namespace Alepha::Hydrogen
return value_lens( t );
}
template< typename T, typename= void >
struct supports_strict_weak_order_lens : std::false_type {};
template< typename T >
struct supports_strict_weak_order_lens< T, std::void_t< decltype( strict_weak_order_lens( std::declval< const T & >() ) ) > > : std::true_type {};
concept StrictWeakOrderLensed=
LensComparable< T >
and
requires( const T &val )
{
{ strict_weak_order_lens( val ) } -> Concepts::LessThanComparable;
};
template< typename T >
constexpr bool supports_strict_weak_order_lens_v= supports_strict_weak_order_lens< T >::value;
template< typename T >
constexpr decltype( auto )
make_strict_weak_order_lens( T &t )
{
if constexpr( supports_strict_weak_order_lens_v< T > ) return strict_weak_order_lens( t );
if constexpr( StrictWeakOrderLensed< T > ) return strict_weak_order_lens( t );
//else if constexpr( supports_default_lens_v< T > ) return default_lens( t );
else static_assert( Meta::dep_value< false, T > );
}