add_member_cv.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_ADD_MEMBER_CV_HPP
  7. #define BOOST_CLBL_TRTS_ADD_MEMBER_CV_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ add_member_cv_hpp
  11. /*`
  12. [section:ref_add_member_cv add_member_cv]
  13. [heading Header]
  14. ``#include <boost/callable_traits/add_member_cv.hpp>``
  15. [heading Definition]
  16. */
  17. template<typename T>
  18. using add_member_cv_t = //see below
  19. //<-
  20. #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  21. detail::sfinae_try<
  22. typename detail::traits<T>::add_member_cv,
  23. detail::fail_when_same<typename detail::traits<T>::add_member_cv,
  24. detail::abominable_functions_not_supported_on_this_compiler,
  25. this_compiler_doesnt_support_abominable_function_types>,
  26. detail::fail_if_invalid<typename detail::traits<T>::add_member_cv,
  27. member_qualifiers_are_illegal_for_this_type>>;
  28. #else
  29. detail::try_but_fail_if_invalid<
  30. typename detail::traits<T>::add_member_cv,
  31. member_qualifiers_are_illegal_for_this_type>;
  32. #endif // #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  33. namespace detail {
  34. template<typename T, typename = std::false_type>
  35. struct add_member_cv_impl {};
  36. template<typename T>
  37. struct add_member_cv_impl <T, typename std::is_same<
  38. add_member_cv_t<T>, detail::dummy>::type>
  39. {
  40. using type = add_member_cv_t<T>;
  41. };
  42. }
  43. //->
  44. template<typename T>
  45. struct add_member_cv : detail::add_member_cv_impl<T> {};
  46. //<-
  47. }} // namespace boost::callable_traits
  48. //->
  49. /*`
  50. [heading Constraints]
  51. * `T` must be a function type or a member function pointer type
  52. * If `T` is a pointer, it may not be cv/ref qualified
  53. [heading Behavior]
  54. * A substitution failure occurs if the constraints are violated.
  55. * Adds member `const` and `volatile` qualifiers to `T`, if not already present.
  56. [heading Input/Output Examples]
  57. [table
  58. [[`T`] [`add_member_cv_t<T>`]]
  59. [[`int()`] [`int() const volatile`]]
  60. [[`int(foo::*)()`] [`int(foo::*)() const volatile`]]
  61. [[`int(foo::*)() &`] [`int(foo::*)() const volatile &`]]
  62. [[`int(foo::*)() &&`] [`int(foo::*)() const volatile &&`]]
  63. [[`int(foo::*)() const`] [`int(foo::*)() const volatile`]]
  64. [[`int(foo::*)() volatile`] [`int(foo::*)() const volatile`]]
  65. [[`int(foo::*)() transaction_safe`] [`int(foo::*)() const volatile transaction_safe`]]
  66. [[`int`] [(substitution failure)]]
  67. [[`int (&)()`] [(substitution failure)]]
  68. [[`int (*)()`] [(substitution failure)]]
  69. [[`int foo::*`] [(substitution failure)]]
  70. [[`int (foo::* const)()`] [(substitution failure)]]
  71. ]
  72. [heading Example Program]
  73. [import ../example/add_member_cv.cpp]
  74. [add_member_cv]
  75. [endsect]
  76. */
  77. //]
  78. #endif