| 1 | #ifndef BOOST_BIND_DETAIL_RESULT_TRAITS_HPP_INCLUDED |
| 2 | #define BOOST_BIND_DETAIL_RESULT_TRAITS_HPP_INCLUDED |
| 3 | |
| 4 | // MS compatible compilers support #pragma once |
| 5 | |
| 6 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
| 7 | # pragma once |
| 8 | #endif |
| 9 | |
| 10 | // |
| 11 | // bind/detail/result_traits.hpp |
| 12 | // |
| 13 | // boost/bind.hpp support header, return type deduction |
| 14 | // |
| 15 | // Copyright 2006, 2020 Peter Dimov |
| 16 | // |
| 17 | // Distributed under the Boost Software License, Version 1.0. |
| 18 | // See accompanying file LICENSE_1_0.txt or copy at |
| 19 | // http://www.boost.org/LICENSE_1_0.txt |
| 20 | // |
| 21 | // See http://www.boost.org/libs/bind/bind.html for documentation. |
| 22 | // |
| 23 | |
| 24 | #include <boost/config.hpp> |
| 25 | #include <boost/core/ref.hpp> |
| 26 | |
| 27 | #if BOOST_CXX_VERSION >= 201700L |
| 28 | #include <functional> |
| 29 | #endif |
| 30 | |
| 31 | namespace boost |
| 32 | { |
| 33 | |
| 34 | namespace _bi |
| 35 | { |
| 36 | |
| 37 | template<class R, class F> struct result_traits |
| 38 | { |
| 39 | typedef R type; |
| 40 | }; |
| 41 | |
| 42 | struct unspecified {}; |
| 43 | |
| 44 | template<class F> struct result_traits<unspecified, F> |
| 45 | { |
| 46 | typedef typename F::result_type type; |
| 47 | }; |
| 48 | |
| 49 | template<class F> struct result_traits< unspecified, reference_wrapper<F> > |
| 50 | { |
| 51 | typedef typename F::result_type type; |
| 52 | }; |
| 53 | |
| 54 | #if BOOST_CXX_VERSION >= 201700L |
| 55 | |
| 56 | template<class T> struct result_traits< unspecified, std::plus<T> > |
| 57 | { |
| 58 | typedef T type; |
| 59 | }; |
| 60 | |
| 61 | template<class T> struct result_traits< unspecified, std::minus<T> > |
| 62 | { |
| 63 | typedef T type; |
| 64 | }; |
| 65 | |
| 66 | template<class T> struct result_traits< unspecified, std::multiplies<T> > |
| 67 | { |
| 68 | typedef T type; |
| 69 | }; |
| 70 | |
| 71 | template<class T> struct result_traits< unspecified, std::divides<T> > |
| 72 | { |
| 73 | typedef T type; |
| 74 | }; |
| 75 | |
| 76 | template<class T> struct result_traits< unspecified, std::modulus<T> > |
| 77 | { |
| 78 | typedef T type; |
| 79 | }; |
| 80 | |
| 81 | template<class T> struct result_traits< unspecified, std::negate<T> > |
| 82 | { |
| 83 | typedef T type; |
| 84 | }; |
| 85 | |
| 86 | template<class T> struct result_traits< unspecified, std::equal_to<T> > |
| 87 | { |
| 88 | typedef bool type; |
| 89 | }; |
| 90 | |
| 91 | template<class T> struct result_traits< unspecified, std::not_equal_to<T> > |
| 92 | { |
| 93 | typedef bool type; |
| 94 | }; |
| 95 | |
| 96 | template<class T> struct result_traits< unspecified, std::greater<T> > |
| 97 | { |
| 98 | typedef bool type; |
| 99 | }; |
| 100 | |
| 101 | template<class T> struct result_traits< unspecified, std::less<T> > |
| 102 | { |
| 103 | typedef bool type; |
| 104 | }; |
| 105 | |
| 106 | template<class T> struct result_traits< unspecified, std::greater_equal<T> > |
| 107 | { |
| 108 | typedef bool type; |
| 109 | }; |
| 110 | |
| 111 | template<class T> struct result_traits< unspecified, std::less_equal<T> > |
| 112 | { |
| 113 | typedef bool type; |
| 114 | }; |
| 115 | |
| 116 | template<class T> struct result_traits< unspecified, std::logical_and<T> > |
| 117 | { |
| 118 | typedef bool type; |
| 119 | }; |
| 120 | |
| 121 | template<class T> struct result_traits< unspecified, std::logical_or<T> > |
| 122 | { |
| 123 | typedef bool type; |
| 124 | }; |
| 125 | |
| 126 | template<class T> struct result_traits< unspecified, std::logical_not<T> > |
| 127 | { |
| 128 | typedef bool type; |
| 129 | }; |
| 130 | |
| 131 | template<class T> struct result_traits< unspecified, std::bit_and<T> > |
| 132 | { |
| 133 | typedef T type; |
| 134 | }; |
| 135 | |
| 136 | template<class T> struct result_traits< unspecified, std::bit_or<T> > |
| 137 | { |
| 138 | typedef T type; |
| 139 | }; |
| 140 | |
| 141 | template<class T> struct result_traits< unspecified, std::bit_xor<T> > |
| 142 | { |
| 143 | typedef T type; |
| 144 | }; |
| 145 | |
| 146 | #if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 40900 |
| 147 | |
| 148 | // libstdc++ 4.8 and below don't have std::bit_not |
| 149 | |
| 150 | #else |
| 151 | |
| 152 | template<class T> struct result_traits< unspecified, std::bit_not<T> > |
| 153 | { |
| 154 | typedef T type; |
| 155 | }; |
| 156 | |
| 157 | #endif |
| 158 | |
| 159 | #endif |
| 160 | |
| 161 | } // namespace _bi |
| 162 | |
| 163 | } // namespace boost |
| 164 | |
| 165 | #endif // #ifndef BOOST_BIND_DETAIL_RESULT_TRAITS_HPP_INCLUDED |
| 166 | |