From c5c65daea2b10cdf4ce455b9103f4a48cad62455 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Tue, 31 Oct 2023 02:24:49 -0400 Subject: [PATCH] Start module renames on some reflection things. --- Reflection/aggregate_initialization.h | 72 ------------------------- Reflection/aggregate_initializer_size.h | 68 +++++++++++++++++++++++ Reflection/aggregate_members.h | 2 +- tuplize_args.h | 6 +-- 4 files changed, 72 insertions(+), 76 deletions(-) delete mode 100644 Reflection/aggregate_initialization.h create mode 100644 Reflection/aggregate_initializer_size.h diff --git a/Reflection/aggregate_initialization.h b/Reflection/aggregate_initialization.h deleted file mode 100644 index 3fd4b6b..0000000 --- a/Reflection/aggregate_initialization.h +++ /dev/null @@ -1,72 +0,0 @@ -static_assert( __cplusplus > 2020'00 ); - -#pragma once - -#include - -#include -#include -#include - -#include - -namespace Alepha::Hydrogen::Reflection -{ - inline namespace exports { inline namespace aggregate_initialization {} } - - namespace detail::aggregate_initialization - { - inline namespace exports {} - - // Basic methodology here: I probe the number of arguments that an object can be constructed with. I don't - // care what they actually are, as there's no easy way to hoist out what they are. However, for an aggregate, - // the largest number of items one can initialize it with is related to the number of items that it contains. - // Therefore as long as the inspection is performed on aggregates and yields the maximum number it finds, then - // it will always yield a valid initialization pack count. Other information is then used to winnow that - // down to arrive at a member count. - - // The basic adaptable argument. Because it pretends to be anything, it can be used as a parameter in invoking - // any initialization method. - struct argument - { - template< typename T > constexpr operator T (); - }; - - // 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 seq= std::index_sequence<>, typename= void, typename= std::enable_if_t< std::is_aggregate_v< T > > > - struct init_count_impl - // When this base case is reached, the size of the sequence is the argument count. - : std::integral_constant< std::size_t, seq::size() > {}; - - // This expansion case always matches when an initializer of the number of elements in the sequence is syntactically - // valid. It also recurses, thus exploring the whole initializer set. There is one fewer value in the sequence set - // than we use to initialize so that when SFINAE gives up, it defers to the base case above, thus having the right - // count. - template< typename T, std::size_t ... values > - struct init_count_impl - < - T, - std::index_sequence< values... >, - std::void_t< decltype( T{ ( values, std::declval< argument >() )..., std::declval< argument >() } ) >, - void - > - // Descend and take the next element in the sequence. - : init_count_impl< T, std::index_sequence< values..., sizeof...( values ) > > {}; - - namespace exports - { - template< typename T > - constexpr std::size_t aggregate_initializer_size_v= init_count_impl< T >::value; - - template< typename T > - using aggregate_initializer_size= typename init_count_impl< T >::type; - } - } - - namespace exports::aggregate_initialization - { - using namespace detail::aggregate_initialization::exports; - } -} diff --git a/Reflection/aggregate_initializer_size.h b/Reflection/aggregate_initializer_size.h new file mode 100644 index 0000000..247b5b2 --- /dev/null +++ b/Reflection/aggregate_initializer_size.h @@ -0,0 +1,68 @@ +static_assert( __cplusplus > 2020'00 ); + +#pragma once + +#include + +#include +#include +#include + +#include + +namespace Alepha::Hydrogen::Reflection ::detail:: aggregate_initializer_size_m +{ + inline namespace exports {} + + + // Basic methodology here: I probe the number of arguments that an object can be constructed with. I don't + // care what they actually are, as there's no easy way to hoist out what they are. However, for an aggregate, + // the largest number of items one can initialize it with is related to the number of items that it contains. + // Therefore as long as the inspection is performed on aggregates and yields the maximum number it finds, then + // it will always yield a valid initialization pack count. Other information is then used to winnow that + // down to arrive at a member count. + + // The basic adaptable argument. Because it pretends to be anything, it can be used as a parameter in invoking + // any initialization method. + struct argument + { + template< typename T > constexpr operator T (); + }; + + // 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 seq= std::index_sequence<>, typename= void, typename= std::enable_if_t< std::is_aggregate_v< T > > > + struct init_count_impl + // When this base case is reached, the size of the sequence is the argument count. + : std::integral_constant< std::size_t, seq::size() > {}; + + // This expansion case always matches when an initializer of the number of elements in the sequence is syntactically + // valid. It also recurses, thus exploring the whole initializer set. There is one fewer value in the sequence set + // than we use to initialize so that when SFINAE gives up, it defers to the base case above, thus having the right + // count. + template< typename T, std::size_t ... values > + struct init_count_impl + < + T, + std::index_sequence< values... >, + std::void_t< decltype( T{ ( values, std::declval< argument >() )..., std::declval< argument >() } ) >, + void + > + // Descend and take the next element in the sequence. + : init_count_impl< T, std::index_sequence< values..., sizeof...( values ) > > {}; + + namespace exports + { + template< typename T > + constexpr std::size_t aggregate_initializer_size_v= init_count_impl< T >::value; + + template< typename T > + using aggregate_initializer_size= typename init_count_impl< T >::type; + } +} + +namespace Alepha::Hydrogen::Reflection::inline exports::inline aggregate_initializer_size_m +{ + using namespace detail::aggregate_initializer_size_m::exports; +} diff --git a/Reflection/aggregate_members.h b/Reflection/aggregate_members.h index b44bac3..6530cdc 100644 --- a/Reflection/aggregate_members.h +++ b/Reflection/aggregate_members.h @@ -11,7 +11,7 @@ static_assert( __cplusplus > 2020'00 ); #include #include -#include +#include #include #include diff --git a/tuplize_args.h b/tuplize_args.h index fa24001..7bd2e3a 100644 --- a/tuplize_args.h +++ b/tuplize_args.h @@ -23,7 +23,7 @@ static_assert( __cplusplus > 2020'00 ); #include "Concepts.h" #include "type_lisp.h" -namespace Alepha::Hydrogen ::detail:: tuplize_args +namespace Alepha::Hydrogen ::detail:: tuplize_args_m { inline namespace exports @@ -136,7 +136,7 @@ namespace Alepha::Hydrogen ::detail:: tuplize_args } } -namespace Alepha::Hydrogen::inline exports::inline tuplize_args +namespace Alepha::Hydrogen::inline exports::inline tuplize_args_m { - using namespace detail::tuplize_args::exports; + using namespace detail::tuplize_args_m::exports; }