forked from Alepha/Alepha
Terminating condition for ctor count.
This commit is contained in:
@ -37,8 +37,9 @@ namespace Alepha::Hydrogen::Reflection ::detail:: tagged_ctor_count_m
|
|||||||
};
|
};
|
||||||
|
|
||||||
template< typename T, typename ... Args >
|
template< typename T, typename ... Args >
|
||||||
requires Concepts::ConstructibleFrom< T, Args... >
|
requires( Concepts::ConstructibleFrom< T, Args... > )
|
||||||
constexpr void construct( const std::tuple< Args... > & );
|
constexpr void construct( std::tuple< Args... > && );
|
||||||
|
|
||||||
|
|
||||||
template< typename T, typename Tuple >
|
template< typename T, typename Tuple >
|
||||||
concept ConstructibleWithTuple=
|
concept ConstructibleWithTuple=
|
||||||
@ -66,13 +67,31 @@ namespace Alepha::Hydrogen::Reflection ::detail:: tagged_ctor_count_m
|
|||||||
// The first step is to just start it all off with a blank sequence and walk forward from there.
|
// The first step is to just start it all off with a blank sequence and walk forward from there.
|
||||||
// The default arguments cause it to start with the blank sequence, even if it doesn't match this
|
// The default arguments cause it to start with the blank sequence, even if it doesn't match this
|
||||||
// case in the specialization selection.
|
// case in the specialization selection.
|
||||||
template< typename T, typename tag, std::size_t cnt= 0 >
|
template< typename T, typename tag, std::size_t cnt= 0, typename= void >
|
||||||
struct tagged_ctor_count
|
struct tagged_ctor_count
|
||||||
: tagged_ctor_count< T, tag, cnt + 1 > {};
|
: tagged_ctor_count< T, tag, cnt + 1 > {};
|
||||||
|
|
||||||
|
template< typename T, typename tag >
|
||||||
|
struct tagged_ctor_count< T, tag, C::max_ctor_size + 1 >
|
||||||
|
{
|
||||||
|
struct impossible;
|
||||||
|
static_assert( std::is_same_v< impossible, T >, "Max depth reached." );
|
||||||
|
};
|
||||||
|
|
||||||
template< typename T, typename tag, std::size_t depth >
|
template< typename T, typename tag, std::size_t depth >
|
||||||
requires ConstructibleWith< T, tag, depth >
|
struct tagged_ctor_count
|
||||||
struct tagged_ctor_count< T, tag, depth >
|
<
|
||||||
|
T,
|
||||||
|
tag,
|
||||||
|
depth,
|
||||||
|
std::void_t
|
||||||
|
<
|
||||||
|
decltype( construct< T >
|
||||||
|
(
|
||||||
|
std::tuple_cat( std::declval< expand_t< T, depth > >(), std::declval< std::tuple< tag > >() )
|
||||||
|
) )
|
||||||
|
>
|
||||||
|
>
|
||||||
// Size is 1 more than the depth we probed, since that also accounts for the tag.
|
// Size is 1 more than the depth we probed, since that also accounts for the tag.
|
||||||
: std::integral_constant< std::size_t, depth + 1 > {};
|
: std::integral_constant< std::size_t, depth + 1 > {};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user