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