Removed unused helper BoundedArray class
[libcds.git] / cds / details / binary_functor_wrapper.h
1 //$$CDS-header$$
2
3 #ifndef CDSLIB_DETAILS_BINARY_FUNCTOR_WRAPPER_H
4 #define CDSLIB_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     struct trivial_accessor
43     {
44         template <typename T>
45         T const& operator()( T const& p ) const
46         {
47             return p;
48         }
49
50         template <typename T>
51         T& operator()( T& p ) const
52         {
53             return p;
54         }
55     };
56
57     template <typename ArgType, typename Predicate, typename Accessor>
58     using predicate_wrapper = binary_functor_wrapper< bool, Predicate, ArgType, Accessor>;
59
60     template <typename ArgType, typename Compare, typename Accessor>
61     using compare_wrapper = binary_functor_wrapper< int, Compare, ArgType, Accessor>;
62
63 }} // namespace cds::details
64
65 //@endcond
66
67 #endif // #ifndef CDSLIB_DETAILS_BINARY_FUNCTOR_WRAPPER_H