is_noexcept.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. @file is_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_IS_NOEXCEPT_HPP
  8. #define BOOST_CLBL_TRTS_IS_NOEXCEPT_HPP
  9. #include <boost/callable_traits/detail/core.hpp>
  10. namespace boost { namespace callable_traits {
  11. //[ is_noexcept_hpp
  12. /*`[section:ref_is_noexcept is_noexcept]
  13. [heading Header]
  14. ``#include <boost/callable_traits/is_noexcept.hpp>``
  15. [heading Definition]
  16. */
  17. // inherits from either std::true_type or std::false_type
  18. template<typename T>
  19. struct is_noexcept;
  20. //<-
  21. template<typename T>
  22. struct is_noexcept : detail::traits<detail::shallow_decay<T>>::is_noexcept {
  23. using type = typename detail::traits<
  24. detail::shallow_decay<T>>::is_noexcept;
  25. };
  26. #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
  27. template<typename T>
  28. struct is_noexcept_v {
  29. static_assert(std::is_same<T, detail::dummy>::value,
  30. "Variable templates not supported on this compiler.");
  31. };
  32. #else
  33. //->
  34. // only available when variable templates are supported
  35. template<typename T>
  36. //<-
  37. BOOST_CLBL_TRAITS_INLINE_VAR
  38. //->
  39. constexpr bool is_noexcept_v = //see below
  40. //<-
  41. detail::traits<detail::shallow_decay<T>>::is_noexcept::value;
  42. #endif
  43. }} // namespace boost::callable_traits
  44. //->
  45. /*`
  46. [heading Constraints]
  47. * none
  48. *
  49. [heading Behavior]
  50. * `is_noexcept<T>::value` is `true` when either:
  51. * `T` is a function type, function pointer type, function reference type, or member function pointer type where the function has a `noexcept` specifier
  52. * `T` is a function object with a non-overloaded `operator()`, where the `operator()` has a `noexcept` specifier
  53. * On compilers that support variable templates, `is_noexcept_v<T>` is equivalent to `is_noexcept<T>::value`.
  54. [heading Input/Output Examples]
  55. [table
  56. [[`T`] [`is_noexcept_v<T>`]]
  57. [[`int() const noexcept`] [`true`]]
  58. [[`int(* const &)() noexcept`] [`true`]]
  59. [[`int(&)() noexcept`] [`true`]]
  60. [[`int(foo::*)() noexcept`] [`true`]]
  61. [[`int() const`] [`false`]]
  62. [[`int() volatile`] [`false`]]
  63. [[`int(foo::*)() const`] [`false`]]
  64. [[`int() const`] [`false`]]
  65. [[`int() volatile`] [`false`]]
  66. [[`int() &`] [`false`]]
  67. [[`int(*)()`] [`false`]]
  68. [[`int`] [`false`]]
  69. [[`int foo::*`] [`false`]]
  70. [[`const int foo::*`] [`false`]]
  71. ]
  72. [heading Example Program]
  73. [import ../example/is_noexcept.cpp]
  74. [is_noexcept]
  75. [endsect]
  76. */
  77. //]
  78. #endif // #ifndef BOOST_CLBL_TRTS_IS_NOEXCEPT_HPP