| 32 | namespace detail |
| 33 | { |
| 34 | template <class Self, class T> |
| 35 | struct reference_wrapper_base_aux |
| 36 | { |
| 37 | protected: |
| 38 | T &aux_get() const { |
| 39 | return static_cast<Self const *>(this)->get(); |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | template <class Self, class T> struct reference_wrapper_base {}; |
| 44 | |
| 45 | template <class Self, class T, class U> |
| 46 | struct reference_wrapper_base<Self, T(U)> |
| 47 | : public std::unary_function<U, T> |
| 48 | {}; |
| 49 | |
| 50 | template <class Self, class T, class U> |
| 51 | struct reference_wrapper_base<Self, T(*)(U)> |
| 52 | : public std::unary_function<U, T> |
| 53 | {}; |
| 54 | |
| 55 | template <class Self, class T, class U> |
| 56 | struct reference_wrapper_base<Self, T(U::*)()> |
| 57 | : public std::unary_function<U*, T> |
| 58 | , public reference_wrapper_base_aux<Self, T(U::*)()> |
| 59 | { |
| 60 | T operator()(U *u) const { |
| 61 | return (u->*(this->aux_get()))(); |
| 62 | } |
| 63 | T operator()(U &u) const { |
| 64 | return operator()(&u); |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | template <class Self, class T, class U> |
| 69 | struct reference_wrapper_base<Self, T(U::*)() const> |
| 70 | : public std::unary_function<const U*, T> |
| 71 | , public reference_wrapper_base_aux<Self, T(U::*)() const> |
| 72 | { |
| 73 | T operator()(const U *u) const { |
| 74 | return (u->*(this->aux_get()))(); |
| 75 | } |
| 76 | T operator()(const U &u) const { |
| 77 | return operator()(&u); |
| 78 | } |
| 79 | }; |
| 80 | |
| 81 | template <class Self, class T, class U, class V> |
| 82 | struct reference_wrapper_base<Self, T(U, V)> |
| 83 | : public std::binary_function<U, V, T> |
| 84 | {}; |
| 85 | |
| 86 | template <class Self, class T, class U, class V> |
| 87 | struct reference_wrapper_base<Self, T(*)(U, V)> |
| 88 | : public std::binary_function<U, V, T> |
| 89 | {}; |
| 90 | |
| 91 | template <class Self, class T, class U, class V> |
| 92 | struct reference_wrapper_base<Self, T(U::*)(V)> |
| 93 | : public std::binary_function<U*, V, T> |
| 94 | , public reference_wrapper_base_aux<Self, T(U::*)(V)> |
| 95 | { |
| 96 | T operator()(U *u, V &v) const { |
| 97 | return (u->*(this->aux_get()))(v); |
| 98 | } |
| 99 | T operator()(U *u, const V &v) const { |
| 100 | return (u->*(this->aux_get()))(v); |
| 101 | } |
| 102 | T operator()(U &u, V &v) const { |
| 103 | return operator()(&u, &v); |
| 104 | } |
| 105 | T operator()(U &u, const V &v) const { |
| 106 | return operator()(&u, &v); |
| 107 | } |
| 108 | }; |
| 109 | |
| 110 | template <class Self, class T, class U, class V> |
| 111 | struct reference_wrapper_base<Self, T(U::*)(V) const> |
| 112 | : public std::binary_function<const U*, V, T> |
| 113 | , public reference_wrapper_base_aux<Self, T(U::*)(V)const> |
| 114 | { |
| 115 | T operator()(const U *u, V &v) const { |
| 116 | return (u->*(this->aux_get()))(v); |
| 117 | } |
| 118 | T operator()(const U *u, const V &v) const { |
| 119 | return (u->*(this->aux_get()))(v); |
| 120 | } |
| 121 | T operator()(const U &u, V &v) const { |
| 122 | return operator()(&u, &v); |
| 123 | } |
| 124 | T operator()(const U &u, const V &v) const { |
| 125 | return operator()(&u, &v); |
| 126 | } |
| 127 | }; |
| 128 | } |