HepMC3 event record library
Public Types | Public Member Functions | Protected Attributes
Feature< Feature_type, typename std::enable_if< std::is_integral< Feature_type >::value, void >::type > Class Template Reference

Specialisation of Feature for integral types. More...

#include <Feature.h>

+ Inheritance diagram for Feature< Feature_type, typename std::enable_if< std::is_integral< Feature_type >::value, void >::type >:
+ Collaboration diagram for Feature< Feature_type, typename std::enable_if< std::is_integral< Feature_type >::value, void >::type >:

Public Types

using Evaluator_type = std::function< Feature_type(ConstGenParticlePtr)>
 
using EvaluatorPtr = std::shared_ptr< Evaluator_type >
 

Public Member Functions

 Feature (Evaluator_type functor)
 
 Feature (const Feature &copy)
 
Feature< Feature_type > abs () const
 
Filter operator> (double value) const
 
Filter operator< (double value) const
 
Filter operator== (double value) const
 
Filter operator>= (double value) const
 
Filter operator<= (double value) const
 
Filter operator!= (double value) const
 
Feature_type operator() (ConstGenParticlePtr input) const
 access the underlying feature value More...
 
Filter operator> (Feature_type value) const
 greater than operator More...
 
Filter operator< (Feature_type value) const
 less than operator More...
 
Filter operator>= (Feature_type value) const
 greater than or equals operator More...
 
Filter operator<= (Feature_type value) const
 less than or equals operator More...
 
virtual Filter operator== (Feature_type value) const
 equality operator More...
 
virtual Filter operator!= (Feature_type value) const
 inequality operator More...
 

Protected Attributes

EvaluatorPtr m_internal
 

Detailed Description

template<typename Feature_type>
class HepMC3::Feature< Feature_type, typename std::enable_if< std::is_integral< Feature_type >::value, void >::type >

Specialisation of Feature for integral types.

It is a valid operator to compare an int to a float, but the generic version of these operators in the base class will first cast input float to an int, then compare that. In some cases the comparison will be incorrect because of rounding the float. e.g. int x=5; float y=5.5; bool result = x<y; would be wrong because y first gets converted to int 5.

To solve this, we provide specialised comparison operators for integral type and double. Note that the opposite specialisation in which the Feature_type is floating_point is not necessary

Definition at line 204 of file Feature.h.

Member Function Documentation

virtual Filter operator!= ( Feature_type  value) const
inlinevirtualinherited

inequality operator

Returns
Filter function

Reimplemented in Feature< Feature_type, typename std::enable_if< std::is_floating_point< Feature_type >::value, void >::type >.

Definition at line 104 of file Feature.h.

Feature_type operator() ( ConstGenParticlePtr  input) const
inlineinherited

access the underlying feature value

Definition at line 64 of file Feature.h.

Filter operator< ( Feature_type  value) const
inlineinherited

less than operator

Returns
Filter function

Definition at line 76 of file Feature.h.

Filter operator<= ( Feature_type  value) const
inlineinherited

less than or equals operator

Returns
Filter function

Definition at line 90 of file Feature.h.

virtual Filter operator== ( Feature_type  value) const
inlinevirtualinherited

equality operator

Returns
Filter function

Reimplemented in Feature< Feature_type, typename std::enable_if< std::is_floating_point< Feature_type >::value, void >::type >.

Definition at line 97 of file Feature.h.

Filter operator> ( Feature_type  value) const
inlineinherited

greater than operator

Returns
Filter function

Definition at line 70 of file Feature.h.

Filter operator>= ( Feature_type  value) const
inlineinherited

greater than or equals operator

Returns
Filter function

Definition at line 83 of file Feature.h.


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