forked from Alepha/Alepha
Start migrating some C++17 traits work to Concepts.
This commit is contained in:
@ -17,21 +17,18 @@ namespace Alepha::Hydrogen::Reflection
|
||||
{
|
||||
inline namespace exports {}
|
||||
|
||||
template< typename T, typename= void >
|
||||
struct has_salient_members_constant : std::false_type {};
|
||||
|
||||
template< typename T >
|
||||
struct has_salient_members_constant< T, std::void_t< decltype( T::salient_members ) > >
|
||||
: std::true_type {};
|
||||
|
||||
template< typename T >
|
||||
constexpr bool has_salient_members_constant_v= has_salient_members_constant< T >::value;
|
||||
concept SalientMembers=
|
||||
requires( const T &t )
|
||||
{
|
||||
{ T::salient_members } -> ConvertibleTo< std::size_t >;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
constexpr std::size_t
|
||||
compute_salient_members_count_impl()
|
||||
{
|
||||
if constexpr( has_salient_members_constant_v< T > ) return T::salient_members;
|
||||
if constexpr( SalientMembers< T > ) return T::salient_members;
|
||||
else return aggregate_member_count_v< std::decay_t< T > >;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user