remove_member_const.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_CONST_HPP
  7. #define BOOST_CLBL_TRTS_REMOVE_MEMBER_CONST_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ remove_member_const_hpp
  11. /*`
  12. [section:ref_remove_member_const remove_member_const]
  13. [heading Header]
  14. ``#include <boost/callable_traits/remove_member_const.hpp>``
  15. [heading Definition]
  16. */
  17. template<typename T>
  18. using remove_member_const_t = //see below
  19. //<-
  20. detail::try_but_fail_if_invalid<
  21. typename detail::traits<T>::remove_member_const,
  22. member_qualifiers_are_illegal_for_this_type>;
  23. namespace detail {
  24. template<typename T, typename = std::false_type>
  25. struct remove_member_const_impl {};
  26. template<typename T>
  27. struct remove_member_const_impl <T, typename std::is_same<
  28. remove_member_const_t<T>, detail::dummy>::type>
  29. {
  30. using type = remove_member_const_t<T>;
  31. };
  32. }
  33. //->
  34. template<typename T>
  35. struct remove_member_const : detail::remove_member_const_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 the member `const` qualifier from `T`, if present.
  46. [heading Input/Output Examples]
  47. [table
  48. [[`T`] [`remove_member_const_t<T>`]]
  49. [[`int() const`] [`int()`]]
  50. [[`int(foo::*)() const`] [`int(foo::*)()`]]
  51. [[`int(foo::*)() const &`] [`int(foo::*)() &`]]
  52. [[`int(foo::*)() const &&`] [`int(foo::*)() &&`]]
  53. [[`int(foo::*)() const`] [`int(foo::*)()`]]
  54. [[`int(foo::*)() const volatile`] [`int(foo::*)() volatile`]]
  55. [[`int`] [(substitution failure)]]
  56. [[`int (&)()`] [(substitution failure)]]
  57. [[`int (*)()`] [(substitution failure)]]
  58. [[`int foo::*`] [(substitution failure)]]
  59. [[`int (foo::* const)()`] [(substitution failure)]]
  60. ]
  61. [heading Example Program]
  62. [import ../example/remove_member_const.cpp]
  63. [remove_member_const]
  64. [endsect]
  65. */
  66. //]
  67. #endif // #ifndef BOOST_CLBL_TRTS_REMOVE_MEMBER_CONST_HPP