Belle II Software development
|
This is a class template which takes a template class operation as template argument. More...
#include <CutNodes.h>
Public Member Functions | |
bool | operator() (const double &val0, const double &val1) |
double double overload with double comparison. | |
bool | operator() (const double &val0, const int &val1) |
double int overload with double comparison. | |
bool | operator() (const double &val0, const bool &val1) |
double bool overload with double comparison. | |
bool | operator() (const int &val0, const int &val1) |
int int overload with int comparison. | |
bool | operator() (const int &val0, const bool &val1) |
int bool overload with int comparison. | |
bool | operator() (const int &val0, const double &val1) |
int double overload with double comparison. | |
bool | operator() (const bool &val0, const bool &val1) |
bool bool overload with bool comparison. | |
bool | operator() (const bool &val0, const double &val1) |
bool double overload with double comparison. | |
bool | operator() (const bool &val0, const int &val1) |
bool int overload with int comparison. | |
This is a class template which takes a template class operation as template argument.
This allows passing the functional class templates e.g std::greater<T>, which are templates themselves.
In the Nodes we often have to compare two node evaluation results with each other. They are of type variant<double, int, bool>
. Variants cannot be compared to each other directly, you have to extract the values and compare them. This gives nine different combinations for two variants. C++ introduced the std::visit concept for this purpose of variant evaluation. std::visit takes a Visitor class and the variants as parameters. One way to write a Visitor is the following way, where a operator() overload is supplied for every data type combination the variants can have. The visitor has to be exhaustive (every data type combination must be covered), and every operator() overload has to have the same return type.
We have to do this comparisons for all comparison operators e.g ==, !=, > ... We can do this by passing the corresponding functional class template e.g std::equal_to<T>, std::not_equal_to<T>, std::greater<T> The datatype T is substituted in the operator() overload depending on the data type combination.
When comparing double/int and a bool the double/int overload of the functionals are used to disable implicit conversion to bool: std::equal_to<bool>{}(1.2, true) ==> true; 1.2 is implicitly converted to true, because of std::equal<bool> std::equal_to<double>{}(1.2, true) ==> false; true is implicity converted to 1.0, because of std::equal<double>
Definition at line 55 of file CutNodes.h.
|
inline |
bool bool overload with bool comparison.
Definition at line 101 of file CutNodes.h.
|
inline |
bool double overload with double comparison.
Definition at line 108 of file CutNodes.h.
|
inline |
bool int overload with int comparison.
Definition at line 115 of file CutNodes.h.
|
inline |
double bool overload with double comparison.
Definition at line 73 of file CutNodes.h.
|
inline |
double double overload with double comparison.
Definition at line 59 of file CutNodes.h.
|
inline |
double int overload with double comparison.
Definition at line 66 of file CutNodes.h.
|
inline |
int bool overload with int comparison.
Definition at line 87 of file CutNodes.h.
|
inline |
int double overload with double comparison.
Definition at line 94 of file CutNodes.h.
|
inline |
int int overload with int comparison.
Definition at line 80 of file CutNodes.h.