Adapter of a category function to find the common category of several objects.
More...
#include <Common.h>
|
template<class Ts, class Category = decltype(m_functor(*std::declval<Ts>().begin()))> |
std::optional< Category > | operator() (const Ts &ts) const |
| Returns the common category value of a range.
|
|
template<class T1, class T2, class Category = decltype(m_functor(std::declval<T1>()))> |
std::optional< Category > | operator() (const T1 &t1, const T2 &t2) const |
| Returns the common category of two values.
|
|
|
AFunctor | m_functor |
| Memory for the nested functor.
|
|
template<class AFunctor>
struct Belle2::TrackFindingCDC::Common< AFunctor >
Adapter of a category function to find the common category of several objects.
Definition at line 19 of file Common.h.
◆ operator()() [1/2]
template<class AFunctor>
template<class T1, class T2, class Category = decltype(m_functor(std::declval<T1>()))>
std::optional< Category > operator() |
( |
const T1 & | t1, |
|
|
const T2 & | t2 ) const |
|
inline |
Returns the common category of two values.
In case the category value differ between the values return empty optional
Definition at line 50 of file Common.h.
51 {
52 Category cat1 = m_functor(t1);
53 Category cat2 = m_functor(t2);
54 if (cat1 == cat2) return {cat1};
55 return {};
56 }
◆ operator()() [2/2]
template<class AFunctor>
template<class Ts, class Category = decltype(m_functor(*std::declval<Ts>().begin()))>
std::optional< Category > operator() |
( |
const Ts & | ts | ) |
const |
|
inline |
Returns the common category value of a range.
In case the category value differ between the values return empty optional.
Definition at line 32 of file Common.h.
33 {
34 auto it = std::begin(ts);
35 auto itEnd = std::end(ts);
36 if (it == itEnd) return {};
37 Category category = m_functor(*it);
38 for (; it != itEnd; ++it) {
39 if (category != m_functor(*it)) return {};
40 }
41 return {category};
42 }
◆ m_functor
Memory for the nested functor.
Definition at line 23 of file Common.h.
The documentation for this struct was generated from the following file:
- tracking/trackFindingCDC/utilities/include/Common.h