37template <is::stdTuple... ArgTuples>
41 template <
class... Args>
42 requires (! (is::stdTuple<Args> || ...))
43 constexpr RuntimeArgChain (Args... firstArgs)
44 : chain {{ std::tuple (std::move (firstArgs)...) }}
47 constexpr RuntimeArgChain()
48 requires (
sizeof... (ArgTuples) == 1)
49 : chain {{ std::tuple<>() }}
53 constexpr RuntimeArgChain()
54 requires (
sizeof... (ArgTuples) == 3)
55 : chain {{ std::tuple<>() }, { std::tuple<>() }, { std::tuple<>() }}
58 static constexpr size_t size() {
return sizeof... (ArgTuples); }
60 template <is::stdTuple... ArgTuplesToPrepend>
61 constexpr RuntimeArgChain<ArgTuplesToPrepend..., ArgTuples...> prepend (RuntimeArgChain<ArgTuplesToPrepend...> chainToPrepend)
const
63 return { std::tuple_cat (chainToPrepend.chain, chain) };
67 static constexpr bool hasValue()
69 return ! std::is_same_v<std::tuple<>, std::tuple_element_t<idx,
decltype (chain)>>;
73 constexpr auto& get()
const
75 return std::get<idx> (chain);
79 template <is::stdTuple...>
friend class RuntimeArgChain;
81 constexpr RuntimeArgChain (std::tuple<ArgTuples...>&& newChain)
82 : chain (std::move (newChain))
85 std::tuple<ArgTuples...> chain;
88template <
class SrcChainer,
template <
size_t,
class>
class ExpressionToAdd>
89struct ExpressionChainingHelper
91 template <
size_t extent,
class SrcType>
92 using NewExpressionChain = ExpressionToAdd<extent, typename SrcChainer::template Expression<extent, SrcType>>;
94 template <
class RuntimeArgs>
95 using NewExpressionChainBuilder = ExpressionChainBuilderWithRuntimeArgs<NewExpressionChain, RuntimeArgs>;
102template <auto constantValue>
105 static constexpr auto value = constantValue;
111template <const auto& range>
115 static constexpr auto value = range.getStart();
121template <const auto& range>
125 static constexpr auto value = range.getEnd();
135 template <is::realNumber T>
136 constexpr operator T()
const {
return std::numeric_limits<T>::max(); }
138 template <is::realNumber T>
139 constexpr operator std::complex<T>()
const {
return { std::numeric_limits<T>::max(), std::numeric_limits<T>::max() }; }
142 static constexpr Value value {};
155template <
template <size_t,
class...>
class ExpressionType,
class RuntimeArgs,
class... AdditionalCompileTimeParameters>
158 template <
size_t extent,
class SrcType>
159 using Expression = ExpressionType<extent, SrcType, AdditionalCompileTimeParameters...>;
161 RuntimeArgs runtimeArgs;
164 : runtimeArgs (std::move (rtArgs))
170 template <is::anyVctr Src>
173 auto expression = Expression<extentOf<Src>,
const Src&> { src };
174 expression.template iterateOverRuntimeArgChain<0> (runtimeArgs);
187 template <is::anyVctr Src>
190 auto expression = Expression<extentOf<Src>,
const Src&> { src };
191 expression.template iterateOverRuntimeArgChain<0> (runtimeArgs);
204 template <is::anyVctr Src>
207 auto expression = Expression<extentOf<Src>, Src> { std::move (src) };
208 expression.template iterateOverRuntimeArgChain<0> (runtimeArgs);
221 template <is::expression SrcExpression>
224 auto expression = Expression<extentOf<SrcExpression>, SrcExpression> (std::forward<SrcExpression> (e));
225 expression.template iterateOverRuntimeArgChain<0> (runtimeArgs);
240 template <is::expressionChainBuilder SrcExpressionChainBuilder>
241 constexpr auto operator<< (SrcExpressionChainBuilder srcExpressionChainBuilder)
const
243 auto newRuntimeArgChain = srcExpressionChainBuilder.runtimeArgs.prepend (runtimeArgs);
245 using ChainingHelper = detail::ExpressionChainingHelper<SrcExpressionChainBuilder, Expression>;
247 return typename ChainingHelper::template NewExpressionChainBuilder<decltype(newRuntimeArgChain)> (std::move (newRuntimeArgChain));
252template <
template <size_t,
class...>
class ExpressionType,
class... AdditionalCompileTimeParameters>
276template <
template <size_t,
class...>
class ExpressionType,
class... RuntimeArgs>
277requires (
sizeof... (RuntimeArgs) > 0)
280 return ExpressionChainBuilderWithRuntimeArgs<ExpressionType, detail::RuntimeArgChain<std::tuple<RuntimeArgs...>>> (detail::RuntimeArgChain<std::tuple<RuntimeArgs...>> (std::move (runtimeArgs)...));
288template <
template <size_t,
class...>
class ExpressionType,
class ExpressionTemplateArg,
class... RuntimeArgs>
289requires (
sizeof... (RuntimeArgs) > 0)
292 return ExpressionChainBuilderWithRuntimeArgs<ExpressionType, detail::RuntimeArgChain<std::tuple<RuntimeArgs...>>, ExpressionTemplateArg> (detail::RuntimeArgChain<std::tuple<RuntimeArgs...>> (std::move (runtimeArgs)...));
static VCTR_FORCEDINLINE constexpr auto reduce(const Expression &e)
Returns the reduction result of the expression passed in.
Definition: ReductionExpression.h:42
Constrains the type to be a range, this is a class with a getStart, getLength and getEnd member funct...
Definition: GenericConcepts.h:125
Definition: ContainerAndExpressionConcepts.h:387
The main namespace of the VCTR project.
Definition: Array.h:24
constexpr auto makeTemplateExpressionChainBuilderWithRuntimeArgs(RuntimeArgs... runtimeArgs)
Helper function to build factory functions for expressions that rely on runtime argument values.
Definition: ExpressionChainBuilder.h:290
constexpr auto makeExpressionChainBuilderWithRuntimeArgs(RuntimeArgs... runtimeArgs)
Helper function to build factory functions for expressions that rely on runtime argument values.
Definition: ExpressionChainBuilder.h:278
Evaluates the return value of getEnd called on the constant reference template argument and wraps tha...
Definition: ExpressionChainBuilder.h:124
Evaluates the return value of getStart called on the constant reference template argument and wraps t...
Definition: ExpressionChainBuilder.h:114
A helper struct to pass a constant as argument wrapped in a struct with a single public static conste...
Definition: ExpressionChainBuilder.h:104
A stupid type that converts itself to std::numeric_limits<T>::max when assigned to any numeric type T...
Definition: ExpressionChainBuilder.h:134
A helper struct to indicate that a constant template should be considered disabled.
Definition: ExpressionChainBuilder.h:131
An expression chain builder is an object which supplies various operator<< overloads which build chai...
Definition: ExpressionChainBuilder.h:157
constexpr auto operator<<(const Src &src) const
Returns an expression which holds a reference to the Vector passed in as source.
Definition: ExpressionChainBuilder.h:171