cds  2.3.2
cds::opt::less< Functor > Struct Template Reference

[type-option] Option setter for less predicate More...

#include <cds/opt/compare.h>

Detailed Description

template<typename Functor>
struct cds::opt::less< Functor >

[type-option] Option setter for less predicate

The option sets a binary predicate that tests whether a value of a specified type is less than another value of that type. Functor interface is similar to std::less predicate interface. The standard predicate std::less can act as Functor:

In addition, the option setter may sets non-standard 2-type predicate (std::binary_function):

struct foo {
int n;
};
template <typename T, typename Q>
struct pred_less {
bool operator ()( const T& t, const Q& q )
{ return t.n < q ; }
bool operator ()( const Q& q, const T& t )
{ return q < t.n ; }
bool operator ()( const T& t1, const T& t2 )
{ return t1.n < t2.n ; }
bool operator ()( const Q& q1, const Q& q2 )
{ return q1 < q2 ; }
};

Generally, the default type for Functor is std::less but it depends on the container used.

Relation between opt::less and opt::compare option setters
Unless otherwise specified, opt::compare option setter has high priority. If opt::compare and opt::less options are specified for a container, the opt::compare option is used:
// Suppose, a hypothetical map_type allows to specify
// cds::opt::less and cds::opt::compare options
typedef map_type< std::string, int,
> my_map_type;
// For my_map_type, the cds::opt::compare comparator will be used,
// the cds::opt::less option is ignored without any warnings.

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

cds 2.3.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:50 by Doxygen 1.8.13