4 @Copyright Barrett Adair 2015-2017
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_CLBL_TRTS_ADD_NOEXCEPT_HPP
11 #define BOOST_CLBL_TRTS_ADD_NOEXCEPT_HPP
13 #include <boost/callable_traits/detail/core.hpp>
15 namespace boost { namespace callable_traits {
17 BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(add_noexcept)
18 BOOST_CLBL_TRTS_SFINAE_MSG(add_noexcept, cannot_add_noexcept_to_this_type)
20 #ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
22 struct add_noexcept_t {
23 static_assert(std::is_same<T, detail::dummy>::value,
24 "noexcept types not supported by this configuration.");
29 static_assert(std::is_same<T, detail::dummy>::value,
30 "noexcept types not supported by this configuration.");
37 [section:ref_add_noexcept add_noexcept]
39 ``#include <boost/callable_traits/add_noexcept.hpp>``
44 using add_noexcept_t = //see below
46 detail::try_but_fail_if_invalid<
47 typename detail::traits<T>::add_noexcept,
48 cannot_add_noexcept_to_this_type>;
52 template<typename T, typename = std::false_type>
53 struct add_noexcept_impl {};
56 struct add_noexcept_impl <T, typename std::is_same<
57 add_noexcept_t<T>, detail::dummy>::type>
59 using type = add_noexcept_t<T>;
65 struct add_noexcept : detail::add_noexcept_impl<T> {};
68 #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
69 }} // namespace boost::callable_traits
74 * `T` must be one of the following:
76 * function pointer type
77 * function reference type
78 * member function pointer type
79 * If `T` is a pointer, it may not be cv/ref qualified
82 * A substitution failure occurs if the constraints are violated.
83 * Adds a `noexcept` specifier to `T`, if not already present.
85 [heading Input/Output Examples]
87 [[`T`] [`add_noexcept_t<T>`]]
88 [[`int()`] [`int() noexcept`]]
89 [[`int (&)()`] [`int(&)() noexcept`]]
90 [[`int (*)()`] [`int(*)() noexcept`]]
91 [[`int(foo::*)()`] [`int(foo::*)() noexcept`]]
92 [[`int(foo::*)() &`] [`int(foo::*)() & noexcept`]]
93 [[`int(foo::*)() &&`] [`int(foo::*)() && noexcept`]]
94 [[`int(foo::*)() const transaction_safe`] [`int(foo::*)() const transaction_safe noexcept`]]
95 [[`int(foo::*)() noexcept`] [`int(foo::*)() noexcept`]]
96 [[`int`] [(substitution failure)]]
97 [[`int foo::*`] [(substitution failure)]]
98 [[`int (*&)()`] [(substitution failure)]]
101 [heading Example Program]
102 [import ../example/add_noexcept.cpp]
108 #endif // #ifndef BOOST_CLBL_TRTS_ADD_NOEXCEPT_HPP