function.hpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. @Copyright Barrett Adair 2015-2017
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef BOOST_CLBL_TRTS_DETAIL_FUNCTION_HPP
  7. #define BOOST_CLBL_TRTS_DETAIL_FUNCTION_HPP
  8. #include <boost/callable_traits/detail/config.hpp>
  9. #include <boost/callable_traits/detail/qualifier_flags.hpp>
  10. #include <boost/callable_traits/detail/forward_declarations.hpp>
  11. #include <boost/callable_traits/detail/set_function_qualifiers.hpp>
  12. #include <boost/callable_traits/detail/default_callable_traits.hpp>
  13. namespace boost { namespace callable_traits { namespace detail {
  14. template<typename T>
  15. struct function : default_callable_traits<T> {};
  16. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  17. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  18. #include <boost/callable_traits/detail/unguarded/function.hpp>
  19. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  20. #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  21. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const
  22. #include <boost/callable_traits/detail/unguarded/function.hpp>
  23. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  24. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS volatile
  25. #include <boost/callable_traits/detail/unguarded/function.hpp>
  26. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  27. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const volatile
  28. #include <boost/callable_traits/detail/unguarded/function.hpp>
  29. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  30. #ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
  31. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS &
  32. #include <boost/callable_traits/detail/unguarded/function.hpp>
  33. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  34. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS &&
  35. #include <boost/callable_traits/detail/unguarded/function.hpp>
  36. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  37. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const &
  38. #include <boost/callable_traits/detail/unguarded/function.hpp>
  39. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  40. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const &&
  41. #include <boost/callable_traits/detail/unguarded/function.hpp>
  42. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  43. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS volatile &
  44. #include <boost/callable_traits/detail/unguarded/function.hpp>
  45. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  46. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS volatile &&
  47. #include <boost/callable_traits/detail/unguarded/function.hpp>
  48. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  49. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const volatile &
  50. #include <boost/callable_traits/detail/unguarded/function.hpp>
  51. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  52. #define BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS const volatile &&
  53. #include <boost/callable_traits/detail/unguarded/function.hpp>
  54. #undef BOOST_CLBL_TRTS_INCLUDE_QUALIFIERS
  55. #endif // #ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
  56. #endif // #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  57. // function pointers
  58. #define BOOST_CLBL_TRTS_CC_TAG dummy
  59. #define BOOST_CLBL_TRTS_VARARGS_CC BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC
  60. #define BOOST_CLBL_TRTS_CC
  61. #define BOOST_CLBL_TRTS_ST
  62. #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
  63. #include <boost/callable_traits/detail/unguarded/function_ptr_varargs.hpp>
  64. #undef BOOST_CLBL_TRTS_ST
  65. #undef BOOST_CLBL_TRTS_CC
  66. #undef BOOST_CLBL_TRTS_CC_TAG
  67. #undef BOOST_CLBL_TRTS_VARARGS_CC
  68. /* ?
  69. #ifdef BOOST_CLBL_TRTS_ENABLE_CDECL
  70. #define BOOST_CLBL_TRTS_CC_TAG cdecl_tag
  71. #define BOOST_CLBL_TRTS_VARARGS_CC __cdecl
  72. #define BOOST_CLBL_TRTS_CC __cdecl
  73. #define BOOST_CLBL_TRTS_ST
  74. #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
  75. #undef BOOST_CLBL_TRTS_ST
  76. #undef BOOST_CLBL_TRTS_CC
  77. #undef BOOST_CLBL_TRTS_CC_TAG
  78. #undef BOOST_CLBL_TRTS_VARARGS_CC
  79. #endif*/
  80. #ifdef BOOST_CLBL_TRTS_ENABLE_STDCALL
  81. #define BOOST_CLBL_TRTS_CC_TAG stdcall_tag
  82. #define BOOST_CLBL_TRTS_VARARGS_CC BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC
  83. #define BOOST_CLBL_TRTS_CC __stdcall
  84. #define BOOST_CLBL_TRTS_ST
  85. #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
  86. #undef BOOST_CLBL_TRTS_ST
  87. #undef BOOST_CLBL_TRTS_CC
  88. #undef BOOST_CLBL_TRTS_CC_TAG
  89. #undef BOOST_CLBL_TRTS_VARARGS_CC
  90. #endif
  91. #ifdef BOOST_CLBL_TRTS_ENABLE_FASTCALL
  92. #define BOOST_CLBL_TRTS_CC_TAG fastcall_tag
  93. #define BOOST_CLBL_TRTS_VARARGS_CC BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC
  94. #define BOOST_CLBL_TRTS_CC __fastcall
  95. #define BOOST_CLBL_TRTS_ST
  96. #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
  97. #undef BOOST_CLBL_TRTS_CC
  98. #undef BOOST_CLBL_TRTS_ST
  99. #undef BOOST_CLBL_TRTS_CC_TAG
  100. #undef BOOST_CLBL_TRTS_VARARGS_CC
  101. #endif
  102. #ifdef BOOST_CLBL_TRTS_ENABLE_PASCAL
  103. #define BOOST_CLBL_TRTS_CC_TAG pascal_tag
  104. #define BOOST_CLBL_TRTS_VARARGS_CC BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC
  105. #define BOOST_CLBL_TRTS_CC
  106. #define BOOST_CLBL_TRTS_ST pascal
  107. #include <boost/callable_traits/detail/unguarded/function_ptr.hpp>
  108. #undef BOOST_CLBL_TRTS_CC
  109. #undef BOOST_CLBL_TRTS_ST
  110. #undef BOOST_CLBL_TRTS_CC_TAG
  111. #undef BOOST_CLBL_TRTS_VARARGS_CC
  112. #endif
  113. template<typename T>
  114. struct function<T&> : std::conditional<function<T>::value,
  115. function<T>, default_callable_traits<T&>>::type {
  116. static constexpr const bool value = !std::is_pointer<T>::value;
  117. using traits = function;
  118. using base = function<T>;
  119. using type = T&;
  120. using remove_varargs = typename base::remove_varargs&;
  121. using add_varargs = typename base::add_varargs&;
  122. using remove_member_reference = reference_error;
  123. using add_member_lvalue_reference = reference_error;
  124. using add_member_rvalue_reference = reference_error;
  125. using add_member_const = reference_error;
  126. using add_member_volatile = reference_error;
  127. using add_member_cv = reference_error;
  128. using remove_member_const = reference_error;
  129. using remove_member_volatile = reference_error;
  130. using remove_member_cv = reference_error;
  131. template<typename NewReturn>
  132. using apply_return = typename base::template apply_return<NewReturn>&;
  133. using clear_args = typename base::clear_args&;
  134. template<typename... NewArgs>
  135. using push_front = typename base::template push_front<NewArgs...>&;
  136. template<typename... NewArgs>
  137. using push_back = typename base::template push_back<NewArgs...>&;
  138. template<std::size_t Count>
  139. using pop_back = typename base::template pop_back<Count>&;
  140. template<std::size_t Count>
  141. using pop_front = typename base::template pop_front<Count>&;
  142. template<std::size_t Index, typename... NewArgs>
  143. using insert_args = typename base::template insert_args<Index, NewArgs...>&;
  144. template<std::size_t Index, std::size_t Count>
  145. using remove_args = typename base::template remove_args<Index, Count>&;
  146. template<std::size_t Index, typename... NewArgs>
  147. using replace_args = typename base::template replace_args<Index, NewArgs...>&;
  148. };
  149. }}} // namespace boost::callable_traits::detail
  150. #endif // #ifndef BOOST_CLBL_TRTS_DETAIL_FUNCTION_HPP