remove_member_cv.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_REMOVE_MEMBER_CV_HPP
  7. #define BOOST_CLBL_TRTS_REMOVE_MEMBER_CV_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ remove_member_cv_hpp
  11. /*`
  12. [section:ref_remove_member_cv remove_member_cv]
  13. [heading Header]
  14. ``#include <boost/callable_traits/remove_member_cv.hpp>``
  15. [heading Definition]
  16. */
  17. template<typename T>
  18. using remove_member_cv_t = //see below
  19. //<-
  20. detail::try_but_fail_if_invalid<
  21. typename detail::traits<T>::remove_member_cv,
  22. member_qualifiers_are_illegal_for_this_type>;
  23. namespace detail {
  24. template<typename T, typename = std::false_type>
  25. struct remove_member_cv_impl {};
  26. template<typename T>
  27. struct remove_member_cv_impl <T, typename std::is_same<
  28. remove_member_cv_t<T>, detail::dummy>::type>
  29. {
  30. using type = remove_member_cv_t<T>;
  31. };
  32. }
  33. //->
  34. template<typename T>
  35. struct remove_member_cv : detail::remove_member_cv_impl<T> {};
  36. //<-
  37. }} // namespace boost::callable_traits
  38. //->
  39. /*`
  40. [heading Constraints]
  41. * `T` must be a function type or a member function pointer type
  42. * If `T` is a pointer, it may not be cv/ref qualified
  43. [heading Behavior]
  44. * A substitution failure occurs if the constraints are violated.
  45. * Removes member `const` and/or `volatile` qualifiers from `T`, if present.
  46. [heading Input/Output Examples]
  47. [table
  48. [[`T`] [`remove_member_cv_t<T>`]]
  49. [[`int() const volatile`] [`int()`]]
  50. [[`int(foo::*)() const volatile`] [`int(foo::*)()`]]
  51. [[`int(foo::*)() volatile`] [`int(foo::*)()`]]
  52. [[`int(foo::*)() const`] [`int(foo::*)()`]]
  53. [[`int(foo::*)() const &`] [`int(foo::*)() &`]]
  54. [[`int(foo::*)() const &&`] [`int(foo::*)() &&`]]
  55. [[`int(foo::*)() const`] [`int(foo::*)()`]]
  56. [[`int`] [(substitution failure)]]
  57. [[`int (&)()`] [(substitution failure)]]
  58. [[`int (*)()`] [(substitution failure)]]
  59. [[`int foo::*`] [(substitution failure)]]
  60. [[`int (foo::* const)()`] [(substitution failure)]]
  61. ]
  62. [heading Example Program]
  63. [import ../example/remove_member_cv.cpp]
  64. [remove_member_cv]
  65. [endsect]
  66. */
  67. //]
  68. #endif // #ifndef BOOST_CLBL_TRTS_REMOVE_MEMBER_CV_HPP