result_traits.hpp 3.2 KB

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