2 @file add_transaction_safe
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_TRANSACTION_SAFE_HPP
11 #define BOOST_CLBL_TRTS_ADD_TRANSACTION_SAFE_HPP
13 #include <boost/callable_traits/detail/core.hpp>
15 namespace boost { namespace callable_traits {
17 BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(add_transaction_safe)
18 BOOST_CLBL_TRTS_SFINAE_MSG(add_transaction_safe, cannot_add_transaction_safe_to_this_type)
20 #ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
22 struct add_transaction_safe_t {
23 static_assert(std::is_same<T, detail::dummy>::value,
24 "transaction_safe not supported by this configuration.");
28 struct add_transaction_safe {
29 static_assert(std::is_same<T, detail::dummy>::value,
30 "transaction_safe not supported by this configuration.");
35 //[ add_transaction_safe_hpp
37 [section:ref_add_transaction_safe add_transaction_safe]
39 ``#include <boost/callable_traits/add_transaction_safe.hpp>``
45 using add_transaction_safe_t = //see below
47 detail::try_but_fail_if_invalid<
48 typename detail::traits<T>::add_transaction_safe,
49 cannot_add_transaction_safe_to_this_type>;
53 template<typename T, typename = std::false_type>
54 struct add_transaction_safe_impl {};
57 struct add_transaction_safe_impl <T, typename std::is_same<
58 add_transaction_safe_t<T>, detail::dummy>::type>
60 using type = add_transaction_safe_t<T>;
66 struct add_transaction_safe
67 : detail::add_transaction_safe_impl<T> {};
70 #endif // #ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
71 }} // namespace boost::callable_traits
76 * `T` must be one of the following:
78 * function pointer type
79 * function reference type
80 * member function pointer type
81 * If `T` is a pointer, it may not be cv/ref qualified
84 * A substitution failure occurs if the constraints are violated.
85 * Adds the `transaction_safe` specifier to `T`, if not already present.
87 [heading Input/Output Examples]
89 [[`T`] [`add_transaction_safe_t<T>`]]
90 [[`int()`] [`int() transaction_safe`]]
91 [[`int (&)()`] [`int(&)() transaction_safe`]]
92 [[`int (*)()`] [`int(*)() transaction_safe`]]
93 [[`int(foo::*)()`] [`int(foo::*)() transaction_safe`]]
94 [[`int(foo::*)() &`] [`int(foo::*)() & transaction_safe`]]
95 [[`int(foo::*)() &&`] [`int(foo::*)() && transaction_safe`]]
96 [[`int(foo::*)() const`] [`int(foo::*)() const transaction_safe`]]
97 [[`int(foo::*)() transaction_safe`] [`int(foo::*)() transaction_safe`]]
98 [[`int`] [(substitution failure)]]
99 [[`int foo::*`] [(substitution failure)]]
100 [[`int (*&)()`] [(substitution failure)]]
103 [heading Example Program]
104 [import ../example/add_transaction_safe.cpp]
105 [add_transaction_safe]
110 #endif // #ifndef BOOST_CLBL_TRTS_ADD_TRANSACTION_SAFE_HPP