Remove CDS_RVALUE_SUPPORT, CDS_MOVE_SEMANTICS_SUPPORT macros and emulating code
[libcds.git] / cds / details / binary_functor_wrapper.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_DETAILS_BINARY_FUNCTOR_WRAPPER_H
4 #define __CDS_DETAILS_BINARY_FUNCTOR_WRAPPER_H
5
6 #include <cds/details/defs.h>
7
8 //@cond
9 namespace cds { namespace details {
10
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;
17
18         return_type operator()( argument_type const& a1, argument_type const& a2 ) const
19         {
20             return functor_type()( accessor()( a1 ), accessor()( a2 ));
21         }
22
23         template <typename Q>
24         return_type operator()( argument_type const& a, Q const& q ) const
25         {
26             return functor_type()( accessor()(a), q );
27         }
28
29         template <typename Q>
30         return_type operator()( Q const& q, argument_type const& a ) const
31         {
32             return functor_type()( q, accessor()(a));
33         }
34
35         template <typename Q1, typename Q2>
36         return_type operator()( Q1 const& q1, Q2 const& q2 ) const
37         {
38             return functor_type()( q1, q2 );
39         }
40     };
41
42     template <typename ArgType, typename Predicate, typename Accessor>
43     using predicate_wrapper = binary_functor_wrapper< bool, Predicate, ArgType, Accessor>;
44
45     template <typename ArgType, typename Compare, typename Accessor>
46     using compare_wrapper = binary_functor_wrapper< int, Compare, ArgType, Accessor>;
47
48 }} // namespace cds::details
49
50 //@endcond
51
52 #endif // #ifndef __CDS_DETAILS_BINARY_FUNCTOR_WRAPPER_H