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;
114 template <is::realNumber T>
115 constexpr operator T()
const {
return std::numeric_limits<T>::max(); }
117 template <is::realNumber T>
118 constexpr operator std::complex<T>()
const {
return { std::numeric_limits<T>::max(), std::numeric_limits<T>::max() }; }
121 static constexpr Value value {};
134template <
template <size_t,
class...>
class ExpressionType,
class RuntimeArgs,
class... AdditionalCompileTimeParameters>
137 template <
size_t extent,
class SrcType>
138 using Expression = ExpressionType<extent, SrcType, AdditionalCompileTimeParameters...>;
140 RuntimeArgs runtimeArgs;
143 : runtimeArgs (std::move (rtArgs))
149 template <is::anyVctr Src>
152 auto expression = Expression<extentOf<Src>,
const Src&> { src };
153 expression.template iterateOverRuntimeArgChain<0> (runtimeArgs);
166 template <is::anyVctr Src>
169 auto expression = Expression<extentOf<Src>,
const Src&> { src };
170 expression.template iterateOverRuntimeArgChain<0> (runtimeArgs);
183 template <is::anyVctr Src>
186 auto expression = Expression<extentOf<Src>, Src> { std::move (src) };
187 expression.template iterateOverRuntimeArgChain<0> (runtimeArgs);
200 template <is::expression SrcExpression>
203 auto expression = Expression<extentOf<SrcExpression>, SrcExpression> (std::forward<SrcExpression> (e));
204 expression.template iterateOverRuntimeArgChain<0> (runtimeArgs);
219 template <is::expressionChainBuilder SrcExpressionChainBuilder>
220 constexpr auto operator<< (SrcExpressionChainBuilder srcExpressionChainBuilder)
const
222 auto newRuntimeArgChain = srcExpressionChainBuilder.runtimeArgs.prepend (runtimeArgs);
224 using ChainingHelper = detail::ExpressionChainingHelper<SrcExpressionChainBuilder, Expression>;
226 return typename ChainingHelper::template NewExpressionChainBuilder<decltype(newRuntimeArgChain)> (std::move (newRuntimeArgChain));
231template <
template <size_t,
class...>
class ExpressionType,
class... AdditionalCompileTimeParameters>
255template <
template <size_t,
class...>
class ExpressionType,
class... RuntimeArgs>
256requires (
sizeof... (RuntimeArgs) > 0)
259 return ExpressionChainBuilderWithRuntimeArgs<ExpressionType, detail::RuntimeArgChain<std::tuple<RuntimeArgs...>>> (detail::RuntimeArgChain<std::tuple<RuntimeArgs...>> (std::move (runtimeArgs)...));
267template <
template <size_t,
class...>
class ExpressionType,
class ExpressionTemplateArg,
class... RuntimeArgs>
268requires (
sizeof... (RuntimeArgs) > 0)
271 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
Definition: ContainerAndExpressionConcepts.h:369
The main namespace of the VCTR project.
Definition: Array.h:24
auto makeTemplateExpressionChainBuilderWithRuntimeArgs(RuntimeArgs... runtimeArgs)
Helper function to build factory functions for expressions that rely on runtime argument values.
Definition: ExpressionChainBuilder.h:269
auto makeExpressionChainBuilderWithRuntimeArgs(RuntimeArgs... runtimeArgs)
Helper function to build factory functions for expressions that rely on runtime argument values.
Definition: ExpressionChainBuilder.h:257
A simple helper struct to pass a constant as argument wrapped in a struct with a single public static...
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:113
A helper struct to indicate that a constant template should be considered disabled.
Definition: ExpressionChainBuilder.h:110
An expression chain builder is an object which supplies various operator<< overloads which build chai...
Definition: ExpressionChainBuilder.h:136
constexpr auto operator<<(const Src &src) const
Returns an expression which holds a reference to the Vector passed in as source.
Definition: ExpressionChainBuilder.h:150