Bayeux  3.4.1
Core Foundation library for SuperNEMO
Public Member Functions | List of all members
datatools::handle_predicate< T > Struct Template Reference

Forward declaration : More...

#include <bayeux/datatools/handle.h>

Inheritance diagram for datatools::handle_predicate< T >:
datatools::i_predicate< handle< T > >

Public Member Functions

 handle_predicate (const i_predicate< T > &predicate_, bool no_data_means_false_=true)
 The default constructor. More...
 
bool operator() (const handle< T > &handle_) const
 Call operator taking handle as input. More...
 

Detailed Description

template<typename T>
struct datatools::handle_predicate< T >

Forward declaration :

Templatized predicate class associated to handle instance.

The handle_predicate class is used to wrap a predicate object to some instance and pass it to some algorithms (typically the std::find_if function)t.

Example:

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
struct is_pi : public i_predicate <double>
{
bool operator () (const double & a_number) const
{
return a_number = M_PI;
}
};
int main (void)
{
is_pi DP;
typedef handle<double> handle_type;
handle_predicate<double> HP (DP);
std::vector<handle_type> values;
values.push_back (handle_type (new double (1.0)));
values.push_back (handle_type (new double (M_PI)));
values.push_back (handle_type (new double (10.0)));
std::vector<handle_type>::const_iterator it =
std::find_if (values.begin (), values.end (), HP);
if (it != values.end ()) std::cout << "Found Pi !" << std::endl;
return 0;
}

Constructor & Destructor Documentation

◆ handle_predicate()

template<typename T >
datatools::handle_predicate< T >::handle_predicate ( const i_predicate< T > &  predicate_,
bool  no_data_means_false_ = true 
)
inline

The default constructor.

Member Function Documentation

◆ operator()()

template<typename T >
bool datatools::handle_predicate< T >::operator() ( const handle< T > &  handle_) const
inlinevirtual

Call operator taking handle as input.

Implements datatools::i_predicate< handle< T > >.


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