3 #ifndef __CDS_DETAILS_BINARY_FUNCTOR_WRAPPER_H
4 #define __CDS_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 #ifdef CDS_CXX11_TEMPLATE_ALIAS_SUPPORT
43 template <typename ArgType, typename Predicate, typename Accessor>
44 using predicate_wrapper = binary_functor_wrapper< bool, Predicate, ArgType, Accessor>;
46 template <typename ArgType, typename Compare, typename Accessor>
47 using compare_wrapper = binary_functor_wrapper< int, Compare, ArgType, Accessor>;
49 template <typename ArgType, typename Predicate, typename Accessor>
50 struct predicate_wrapper: public binary_functor_wrapper< bool, Predicate, ArgType, Accessor>
53 template <typename ArgType, typename Compare, typename Accessor>
54 struct compare_wrapper: public binary_functor_wrapper< int, Compare, ArgType, Accessor >
58 }} // namespace cds::details
62 #endif // #ifndef __CDS_DETAILS_BINARY_FUNCTOR_WRAPPER_H