remove_noexcept.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. @file remove_noexcept
  3. @Copyright Barrett Adair 2015-2017
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_CLBL_TRTS_REMOVE_NOEXCEPT_HPP
  8. #define BOOST_CLBL_TRTS_REMOVE_NOEXCEPT_HPP
  9. #include <boost/callable_traits/detail/core.hpp>
  10. namespace boost { namespace callable_traits {
  11. BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(remove_noexcept)
  12. BOOST_CLBL_TRTS_SFINAE_MSG(remove_noexcept, cannot_remove_noexcept_from_this_type)
  13. //[ remove_noexcept_hpp
  14. /*`
  15. [section:ref_remove_noexcept remove_noexcept]
  16. [heading Header]
  17. ``#include <boost/callable_traits/remove_noexcept.hpp>``
  18. [heading Definition]
  19. */
  20. template<typename T>
  21. using remove_noexcept_t = //see below
  22. //<-
  23. detail::try_but_fail_if_invalid<
  24. typename detail::traits<T>::remove_noexcept,
  25. cannot_remove_noexcept_from_this_type>;
  26. namespace detail {
  27. template<typename T, typename = std::false_type>
  28. struct remove_noexcept_impl {};
  29. template<typename T>
  30. struct remove_noexcept_impl <T, typename std::is_same<
  31. remove_noexcept_t<T>, detail::dummy>::type>
  32. {
  33. using type = remove_noexcept_t<T>;
  34. };
  35. }
  36. //->
  37. template<typename T>
  38. struct remove_noexcept : detail::remove_noexcept_impl<T> {};
  39. //<-
  40. }} // namespace boost::callable_traits
  41. //->
  42. /*`
  43. [heading Constraints]
  44. * `T` must be one of the following:
  45. * function type
  46. * function pointer type
  47. * function reference type
  48. * member function pointer type
  49. * If `T` is a pointer, it may not be cv/ref qualified
  50. [heading Behavior]
  51. * A substitution failure occurs if the constraints are violated.
  52. * Removes the `noexcept` specifier from `T`, if present.
  53. [heading Input/Output Examples]
  54. [table
  55. [[`T`] [`remove_noexcept_t<T>`]]
  56. [[`int() const noexcept`] [`int() const`]]
  57. [[`int(*)() noexcept`] [`int(*)()`]]
  58. [[`int(&)() noexcept`] [`int(&)()`]]
  59. [[`int(foo::*)() noexcept`] [`int(foo::*)()`]]
  60. [[`int() const`] [`int() const`]]
  61. [[`int(*)()`] [`int(*)()`]]
  62. [[`int(&)()`] [`int(&)()`]]
  63. [[`int`] [(substitution failure)]]
  64. [[`int foo::*`] [(substitution failure)]]
  65. [[`int (foo::* const)()`] [(substitution failure)]]
  66. ]
  67. [heading Example Program]
  68. [import ../example/remove_noexcept.cpp]
  69. [remove_noexcept]
  70. [endsect]
  71. */
  72. //]
  73. #endif // #ifndef BOOST_CLBL_TRTS_REMOVE_NOEXCEPT_HPP