30#ifndef BERTINI_ENABLE_PERMUTED_ARGUMENTS
31#define BERTINI_ENABLE_PERMUTED_ARGUMENTS
43 template<
typename T,
typename... Remaining >
49 template<
typename T,
typename... RemainingT >
50 struct IndexByType< T, T, RemainingT... > : std::integral_constant< std::size_t, 0 >
52 static_assert(
IndexByType< T, RemainingT... >::value ==
sizeof...( RemainingT ),
"No duplicates are allowed when enabling permuted arguments" );
56 template<
typename T1,
typename T2,
typename... RemainingT >
57 struct IndexByType< T1, T2, RemainingT... > : std::integral_constant< std::size_t, IndexByType< T1, RemainingT... >::value + 1 >
61 template< std::size_t I, std::size_t J,
62 typename T,
typename... PresentT,
typename... GivenT >
64 const std::tuple< GivenT... >& absent_args )
65 ->
typename std::enable_if< I ==
sizeof...( PresentT ),
const T& >::type
67 return std::get< J >( absent_args );
71 template< std::size_t I, std::size_t J,
72 typename T,
typename... PresentT,
typename... GivenT >
73 auto GetByIndex(
const std::tuple< PresentT... >& present_args,
74 const std::tuple< GivenT... >& )
75 ->
typename std::enable_if< I !=
sizeof...( PresentT ),
const T& >::type
77 return std::get< I >( present_args );
91 template< std::size_t... >
98 template<
typename T >
105 template<
typename T >
115 template<
typename... UnpermutedT,
116 typename... PermutedPresentT >
117 std::tuple<
const UnpermutedT&... >
Unpermute(
const PermutedPresentT&... present_permuted_args )
120 auto present_args = std::tie( present_permuted_args... );
121 auto absent_args = std::tie( DefaultConstruct< UnpermutedT >::value... );
124 ValidateTypes< AreValidArguments< IndexByType<
const PermutedPresentT&,
125 const UnpermutedT&... >::value !=
sizeof...( UnpermutedT )
130 return std::tie( GetByIndex< IndexByType< const UnpermutedT&, const PermutedPresentT&... >::value,
131 IndexByType< const UnpermutedT&, const UnpermutedT&... >::value, UnpermutedT >
132 ( present_args, absent_args )... );
Definition configured.hpp:34
auto GetByIndex(const std::tuple< PresentT... > &, const std::tuple< GivenT... > &absent_args) -> typename std::enable_if< I==sizeof...(PresentT), const T & >::type
Get the value of type T, pulling from the given (absent) args when T is not among the present types.
Definition enable_permuted_arguments.hpp:63
void ValidateTypes()
Proxy function ensuring the types are distinct and indexable by type (compile-time check).
Definition enable_permuted_arguments.hpp:92
Definition algorithm_builder.hpp:36
std::tuple< const UnpermutedT &... > Unpermute(const PermutedPresentT &... present_permuted_args)
Reorder a set of present arguments into the declared UnpermutedT order, default-constructing any abse...
Definition enable_permuted_arguments.hpp:117
Definition enable_permuted_arguments.hpp:84
Holds a default-constructed value of T, used to fill arguments not present when unpermuting.
Definition enable_permuted_arguments.hpp:100
static const T value
The default-constructed value of T.
Definition enable_permuted_arguments.hpp:101
Definition enable_permuted_arguments.hpp:45