40#include "../../misc/compileTimeLoop.hpp"
42#include "../../traits/misc/removeAll.hpp"
43#include "nodeInterface.hpp"
58 template<
typename T_ResultType,
typename T_Impl>
70 template<
typename Node,
typename... Args>
99 template<
typename Node,
typename... Args>
102 return Impl::template
toLinks<Node>(std::forward<Args>(args)...);
112 template<
typename Node,
typename... Args>
115 return Impl::NeutralElement;
127 template<
size_t ChildNumber,
typename Child,
typename Root,
typename... Args>
130 return Impl::template
toNode<Child>(std::forward<Args>(args)...);
137#ifndef DOXYGEN_DISABLE
138 template<
typename TraversalImpl,
bool endPo
int = false>
141 template<
typename Node,
typename... Args>
142 CODI_INLINE static ResultType
constexpr call(Args&&... args) {
143 return TraversalImpl::template node<Node>(std::forward<Args>(args)...);
147 template<
typename TraversalImpl>
148 struct CallSwitch<TraversalImpl, true> {
150 template<
typename Node,
typename... Args>
151 CODI_INLINE static ResultType
constexpr call(Args&&... args) {
152 return TraversalImpl::template leaf<Node>(std::forward<Args>(args)...);
158 template<
typename Node,
typename... Args>
160 return CallSwitch < Impl, 0 == Node::LinkCount > ::template call<Node>(std::forward<Args>(args)...);
166 template<
typename Arg1>
173 template<
typename Arg1,
typename... Args>
175 return Impl::reduce(std::forward<Arg1>(arg1), reduceVariadic(std::forward<Args>(args)...));
180 template<
typename Node, std::size_t... Is,
typename... Args>
182 return reduceVariadic(
183 Impl::template
link<Is,
remove_all<
decltype(std::declval<Node>().
template getLink<Is>())>, Node>(
184 std::forward<Args>(args)...)...);
190 template<
typename Node,
typename... Args>
192 return toLinksImpl<Node>(std::make_index_sequence<Node::LinkCount>(), std::forward<Args>(args)...);
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:96
#define CODI_UNUSED_ARG(arg)
Used in a constexpr context, where using CODI_UNUSED spoils the constexpr.
Definition macros.hpp:57
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
typename std::remove_cv< typename std::remove_reference< typename std::remove_cv< T >::type >::type >::type remove_all
Removes all reference, constant and volatile modifiers.
Definition removeAll.hpp:47
Traversal of CoDiPack expressions during compile time.
Definition compileTimeTraversalLogic.hpp:59
static ResultType constexpr NeutralElement
Definition compileTimeTraversalLogic.hpp:65
T_Impl Impl
See CompileTimeTraversalLogic.
Definition compileTimeTraversalLogic.hpp:63
inlinestatic ResultType constexpr eval(Args &&... args)
Start the evaluation of the logic on the given expression.
Definition compileTimeTraversalLogic.hpp:71
T_ResultType ResultType
See CompileTimeTraversalLogic.
Definition compileTimeTraversalLogic.hpp:62
inlinestatic ResultType constexpr link(Args &&... args)
Called for all links in the expression.
Definition compileTimeTraversalLogic.hpp:128
inlinestatic ResultType constexpr node(Args &&... args)
Called for each node in the expression.
Definition compileTimeTraversalLogic.hpp:100
inlinestatic ResultType constexpr leaf(Args &&...)
Called for all leaf nodes in the expression.
Definition compileTimeTraversalLogic.hpp:113
inlinestatic ResultType constexpr toLinks(Args &&... args)
Helper method which calls the method 'link' on all links of the node and reduces the results.
Definition compileTimeTraversalLogic.hpp:191
inlinestatic ResultType constexpr reduce(ResultType a, ResultType b)
Reduction operation for the results of two links.
Definition compileTimeTraversalLogic.hpp:86
inlinestatic ResultType constexpr toNode(Args &&... args)
Helper method to distinguish between leaf nodes and normal nodes.
Definition compileTimeTraversalLogic.hpp:159