result_traits.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. #if defined(_MSVC_LANG) && _MSVC_LANG >= 17
  21. #include <functional>
  22. #endif
  23. namespace boost
  24. {
  25. namespace _bi
  26. {
  27. template<class R, class F> struct result_traits
  28. {
  29. typedef R type;
  30. };
  31. struct unspecified {};
  32. template<class F> struct result_traits<unspecified, F>
  33. {
  34. typedef typename F::result_type type;
  35. };
  36. template<class F> struct result_traits< unspecified, reference_wrapper<F> >
  37. {
  38. typedef typename F::result_type type;
  39. };
  40. #if defined(_MSVC_LANG) && _MSVC_LANG >= 17
  41. template<class T> struct result_traits< unspecified, std::plus<T> >
  42. {
  43. typedef T type;
  44. };
  45. template<class T> struct result_traits< unspecified, std::minus<T> >
  46. {
  47. typedef T type;
  48. };
  49. template<class T> struct result_traits< unspecified, std::multiplies<T> >
  50. {
  51. typedef T type;
  52. };
  53. template<class T> struct result_traits< unspecified, std::divides<T> >
  54. {
  55. typedef T type;
  56. };
  57. template<class T> struct result_traits< unspecified, std::modulus<T> >
  58. {
  59. typedef T type;
  60. };
  61. template<class T> struct result_traits< unspecified, std::negate<T> >
  62. {
  63. typedef T type;
  64. };
  65. template<class T> struct result_traits< unspecified, std::equal_to<T> >
  66. {
  67. typedef bool type;
  68. };
  69. template<class T> struct result_traits< unspecified, std::not_equal_to<T> >
  70. {
  71. typedef bool type;
  72. };
  73. template<class T> struct result_traits< unspecified, std::greater<T> >
  74. {
  75. typedef bool type;
  76. };
  77. template<class T> struct result_traits< unspecified, std::less<T> >
  78. {
  79. typedef bool type;
  80. };
  81. template<class T> struct result_traits< unspecified, std::greater_equal<T> >
  82. {
  83. typedef bool type;
  84. };
  85. template<class T> struct result_traits< unspecified, std::less_equal<T> >
  86. {
  87. typedef bool type;
  88. };
  89. template<class T> struct result_traits< unspecified, std::logical_and<T> >
  90. {
  91. typedef bool type;
  92. };
  93. template<class T> struct result_traits< unspecified, std::logical_or<T> >
  94. {
  95. typedef bool type;
  96. };
  97. template<class T> struct result_traits< unspecified, std::logical_not<T> >
  98. {
  99. typedef bool type;
  100. };
  101. template<class T> struct result_traits< unspecified, std::bit_and<T> >
  102. {
  103. typedef T type;
  104. };
  105. template<class T> struct result_traits< unspecified, std::bit_or<T> >
  106. {
  107. typedef T type;
  108. };
  109. template<class T> struct result_traits< unspecified, std::bit_xor<T> >
  110. {
  111. typedef T type;
  112. };
  113. template<class T> struct result_traits< unspecified, std::bit_not<T> >
  114. {
  115. typedef T type;
  116. };
  117. #endif
  118. } // namespace _bi
  119. } // namespace boost
  120. #endif // #ifndef BOOST_BIND_DETAIL_RESULT_TRAITS_HPP_INCLUDED