add_member_rvalue_reference.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. @Copyright Barrett Adair 2015-2018
  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_ADD_MEMBER_RVALUE_REFERENCE_HPP
  7. #define BOOST_CLBL_TRTS_ADD_MEMBER_RVALUE_REFERENCE_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ add_member_rvalue_reference_hpp
  11. /*`
  12. [section:ref_add_member_rvalue_reference add_member_rvalue_reference]
  13. [heading Header]
  14. ``#include <boost/callable_traits/add_member_rvalue_reference.hpp>``
  15. [heading Definition]
  16. */
  17. //<-
  18. #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
  19. template<typename T>
  20. struct add_member_rvalue_reference_t {
  21. static_assert(std::is_same<T, detail::dummy>::value,
  22. "Reference member qualifiers are not supported by this configuration.");
  23. };
  24. #else
  25. //->
  26. template<typename T>
  27. using add_member_rvalue_reference_t = //see below
  28. //<-
  29. #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  30. detail::sfinae_try<
  31. typename detail::traits<T>::add_member_rvalue_reference,
  32. detail::fail_when_same<typename detail::traits<T>::add_member_rvalue_reference,
  33. detail::abominable_functions_not_supported_on_this_compiler,
  34. this_compiler_doesnt_support_abominable_function_types>,
  35. detail::fail_if_invalid<typename detail::traits<T>::add_member_rvalue_reference,
  36. member_qualifiers_are_illegal_for_this_type>>;
  37. #else
  38. detail::try_but_fail_if_invalid<
  39. typename detail::traits<T>::add_member_rvalue_reference,
  40. member_qualifiers_are_illegal_for_this_type>;
  41. #endif // #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  42. #endif // #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
  43. namespace detail {
  44. template<typename T, typename = std::false_type>
  45. struct add_member_rvalue_reference_impl {};
  46. template<typename T>
  47. struct add_member_rvalue_reference_impl <T, typename std::is_same<
  48. add_member_rvalue_reference_t<T>, detail::dummy>::type>
  49. {
  50. using type = add_member_rvalue_reference_t<T>;
  51. };
  52. }
  53. //->
  54. template<typename T>
  55. struct add_member_rvalue_reference
  56. : detail::add_member_rvalue_reference_impl<T> {};
  57. //<-
  58. }} // namespace boost::callable_traits
  59. //->
  60. /*`
  61. [heading Constraints]
  62. * `T` must be a function type or a member function pointer type
  63. * If `T` is a pointer, it may not be cv/ref qualified
  64. [heading Behavior]
  65. * A substitution failure occurs if the constraints are violated.
  66. * Adds a member rvalue reference qualifier (`&&`) to `T`, if not already present.
  67. * If an lvalue reference qualifier is present, the lvalue reference qualifier remains (in accordance with reference collapsing rules).
  68. [heading Input/Output Examples]
  69. [table
  70. [[`T`] [`add_member_rvalue_reference_t<T>`]]
  71. [[`int()`] [`int() &&`]]
  72. [[`int(foo::*)()`] [`int(foo::*)() &&`]]
  73. [[`int(foo::*)() &`] [`int(foo::*)() &`]]
  74. [[`int(foo::*)() &&`] [`int(foo::*)() &&`]]
  75. [[`int(foo::*)() const`] [`int(foo::*)() const &&`]]
  76. [[`int(foo::*)() transaction_safe`] [`int(foo::*)() && transaction_safe`]]
  77. [[`int`] [(substitution failure)]]
  78. [[`int (&)()`] [(substitution failure)]]
  79. [[`int (*)()`] [(substitution failure)]]
  80. [[`int foo::*`] [(substitution failure)]]
  81. [[`int (foo::* const)()`] [(substitution failure)]]
  82. ]
  83. [heading Example Program]
  84. [import ../example/add_member_rvalue_reference.cpp]
  85. [add_member_rvalue_reference]
  86. [endsect][/section:ref_add_member_rvalue_reference]
  87. */
  88. //]
  89. #endif