3 #ifndef CDSLIB_DETAILS_BINARY_FUNCTOR_WRAPPER_H
4 #define CDSLIB_DETAILS_BINARY_FUNCTOR_WRAPPER_H
6 #include <cds/details/defs.h>
9 namespace cds { namespace details {
11 template <typename ReturnType, typename Functor, typename ArgType, typename Accessor>
12 struct binary_functor_wrapper {
13 typedef ReturnType return_type;
14 typedef Functor functor_type;
15 typedef ArgType argument_type;
16 typedef Accessor accessor;
18 return_type operator()( argument_type const& a1, argument_type const& a2 ) const
20 return functor_type()( accessor()( a1 ), accessor()( a2 ));
24 return_type operator()( argument_type const& a, Q const& q ) const
26 return functor_type()( accessor()(a), q );
30 return_type operator()( Q const& q, argument_type const& a ) const
32 return functor_type()( q, accessor()(a));
35 template <typename Q1, typename Q2>
36 return_type operator()( Q1 const& q1, Q2 const& q2 ) const
38 return functor_type()( q1, q2 );
42 struct trivial_accessor
45 T const& operator()( T const& p ) const
51 T& operator()( T& p ) const
57 template <typename ArgType, typename Predicate, typename Accessor>
58 using predicate_wrapper = binary_functor_wrapper< bool, Predicate, ArgType, Accessor>;
60 template <typename ArgType, typename Compare, typename Accessor>
61 using compare_wrapper = binary_functor_wrapper< int, Compare, ArgType, Accessor>;
63 }} // namespace cds::details
67 #endif // #ifndef CDSLIB_DETAILS_BINARY_FUNCTOR_WRAPPER_H