From 3707ec5cc2a8bcfe2c3275923f6c43b541657625 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Tue, 19 Mar 2024 15:21:59 -0400 Subject: [PATCH] We can use requires clauses here. But it does seem that I can't remove the repeated defns for the argument extraction. --- Reflection/tagged_ctor_count.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Reflection/tagged_ctor_count.h b/Reflection/tagged_ctor_count.h index b9210f5..13f8663 100644 --- a/Reflection/tagged_ctor_count.h +++ b/Reflection/tagged_ctor_count.h @@ -36,6 +36,10 @@ namespace Alepha::Hydrogen::Reflection ::detail:: tagged_ctor_count_m constexpr operator T (); }; + template< typename T, typename ... Args > + requires( Concepts::ConstructibleFrom< T, Args... > ) + constexpr void construct( const std::tuple< Args... > & ); + template< typename T, typename ... Args > requires( Concepts::ConstructibleFrom< T, Args... > ) constexpr void construct( std::tuple< Args... > && ); @@ -67,7 +71,7 @@ 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 default arguments cause it to start with the blank sequence, even if it doesn't match this // case in the specialization selection. - template< typename T, typename tag, std::size_t cnt= 0, typename= void > + template< typename T, typename tag, std::size_t cnt= 0 > struct tagged_ctor_count : tagged_ctor_count< T, tag, cnt + 1 > {}; @@ -79,19 +83,8 @@ namespace Alepha::Hydrogen::Reflection ::detail:: tagged_ctor_count_m }; template< typename T, typename tag, std::size_t depth > - struct tagged_ctor_count - < - T, - tag, - depth, - std::void_t - < - decltype( construct< T > - ( - std::tuple_cat( std::declval< expand_t< T, depth > >(), std::declval< std::tuple< tag > >() ) - ) ) - > - > + requires( ConstructibleWith< T, tag, depth > ) + struct tagged_ctor_count< T, tag, depth > // Size is 1 more than the depth we probed, since that also accounts for the tag. : std::integral_constant< std::size_t, depth + 1 > {};