Belle II Software development
Alternation< AFunctor1, AFunctor2 > Struct Template Reference

Generic functor to try to functors and choose the first to be applicable. More...

#include <Functional.h>

Public Member Functions

 operator FunctorTag ()
 Marker function for the isFunctor test.
 
 Alternation ()=default
 Allow default construction.
 
 Alternation (const AFunctor1 &functor1, const AFunctor2 &functor2=AFunctor2())
 Constructor from the nested functors.
 
template<class... T>
auto impl (int favouredTag, T &&... t) const -> decltype(m_functor1(std::forward< T >(t)...))
 Implementation applying the first functor. Favoured option.
 
template<class... T>
auto impl (long disfavouredTag, T &&... t) const -> decltype(m_functor2(std::forward< T >(t)...))
 Implementation applying the second functor. Disfavoured option.
 
template<class... T>
auto operator() (T &&... t) const -> decltype(this->impl(0, std::forward< T >(t)...))
 Operator to dispatch to the two functors and returns the first applicable option.
 

Private Attributes

AFunctor1 m_functor1
 Memory for the first nested functor.
 
AFunctor2 m_functor2
 Memory for the second nested functor.
 

Detailed Description

template<class AFunctor1, class AFunctor2>
struct Belle2::TrackFindingCDC::Alternation< AFunctor1, AFunctor2 >

Generic functor to try to functors and choose the first to be applicable.

Definition at line 180 of file Functional.h.

Constructor & Destructor Documentation

◆ Alternation()

Alternation ( const AFunctor1 &  functor1,
const AFunctor2 &  functor2 = AFunctor2() 
)
inlineexplicit

Constructor from the nested functors.

Definition at line 198 of file Functional.h.

199 : m_functor1(functor1)
200 , m_functor2(functor2)
201 {
202 }
AFunctor2 m_functor2
Memory for the second nested functor.
Definition: Functional.h:191
AFunctor1 m_functor1
Memory for the first nested functor.
Definition: Functional.h:188

Member Function Documentation

◆ impl() [1/2]

auto impl ( int  favouredTag,
T &&...  t 
) const -> decltype(m_functor1(std::forward<T>(t)...))
inline

Implementation applying the first functor. Favoured option.

Definition at line 207 of file Functional.h.

209 {
210 return m_functor1(std::forward<T>(t)...);
211 }

◆ impl() [2/2]

auto impl ( long  disfavouredTag,
T &&...  t 
) const -> decltype(m_functor2(std::forward<T>(t)...))
inline

Implementation applying the second functor. Disfavoured option.

Definition at line 215 of file Functional.h.

217 {
218 return m_functor2(std::forward<T>(t)...);
219 }

◆ operator()()

auto operator() ( T &&...  t) const -> decltype(this->impl(0, std::forward<T>(t)...))
inline

Operator to dispatch to the two functors and returns the first applicable option.

Definition at line 224 of file Functional.h.

225 {
226 int dispatchTag = 0;
227 return impl(dispatchTag, std::forward<T>(t)...);
228 }
auto impl(int favouredTag, T &&... t) const -> decltype(m_functor1(std::forward< T >(t)...))
Implementation applying the first functor. Favoured option.
Definition: Functional.h:207

Member Data Documentation

◆ m_functor1

AFunctor1 m_functor1
private

Memory for the first nested functor.

Definition at line 188 of file Functional.h.

◆ m_functor2

AFunctor2 m_functor2
private

Memory for the second nested functor.

Definition at line 191 of file Functional.h.


The documentation for this struct was generated from the following file: