is_transaction_safe.hpp
Go to the documentation of this file.
1 /*
2 @file is_transaction_safe
3 
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)
7 
8 */
9 
10 #ifndef BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE_HPP
11 #define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE_HPP
12 
14 
15 namespace boost { namespace callable_traits {
16 
17 //[ is_transaction_safe_hpp
18 /*`[section:ref_is_transaction_safe is_transaction_safe]
19 [heading Header]
20 ``#include <boost/callable_traits/is_transaction_safe.hpp>``
21 [heading Definition]
22 */
23 
24 
25 // inherits from either std::true_type or std::false_type
26 template<typename T>
27 struct is_transaction_safe;
28 
29 //<-
30 template<typename T>
32  detail::shallow_decay<T>>::is_transaction_safe {
33 
34  using type = typename detail::traits<
36 };
37 
38 #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
39 
40 template<typename T>
41 struct is_transaction_safe_v {
42  static_assert(std::is_same<T, detail::dummy>::value,
43  "Variable templates not supported on this compiler.");
44 };
45 
46 #else
47 //->
48 // only available when variable templates are supported
49 template<typename T>
50 //<-
52 //->
53 constexpr bool is_transaction_safe_v = //see below
54 //<-
55  detail::traits<detail::shallow_decay<T>>::is_transaction_safe::value;
56 
57 #endif
58 
59 }} // namespace boost::callable_traits
60 //->
61 
62 /*`
63 [heading Constraints]
64 * none
65 *
66 [heading Behavior]
67 * `is_transaction_safe<T>::value` is `true` when either:
68  * `T` is a function type, function pointer type, function reference type, or member function pointer type where the function has a `transaction_safe` specifier
69  * `T` is a function object with a non-overloaded `operator()`, where the `operator()` has a `transaction_safe` specifier
70 * On compilers that support variable templates, `is_transaction_safe_v<T>` is equivalent to `is_transaction_safe<T>::value`.
71 
72 [heading Input/Output Examples]
73 [table
74  [[`T`] [`is_transaction_safe_v<T>`]]
75  [[`int() const transaction_safe`] [`true`]]
76  [[`int(*)() transaction_safe`] [`true`]]
77  [[`int(&)() transaction_safe`] [`true`]]
78  [[`int(foo::* const)() transaction_safe`] [`true`]]
79  [[`int() const`] [`false`]]
80  [[`int() volatile`] [`false`]]
81  [[`int(foo::*)() const`] [`false`]]
82  [[`int() const`] [`false`]]
83  [[`int() volatile`] [`false`]]
84  [[`int() &`] [`false`]]
85  [[`int(*)()`] [`false`]]
86  [[`int`] [`false`]]
87  [[`int foo::*`] [`false`]]
88  [[`const int foo::*`] [`false`]]
89 ]
90 
91 [heading Example Program]
92 [import ../example/is_transaction_safe.cpp]
93 [is_transaction_safe]
94 [endsect]
95 */
96 //]
97 
98 #endif // #ifndef BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE_HPP
#define BOOST_CLBL_TRAITS_INLINE_VAR
Definition: config.hpp:27
typename std::remove_cv< typename std::remove_reference< T >::type >::type shallow_decay
Definition: utility.hpp:79
typename BOOST_CLBL_TRTS_DISJUNCTION(function_object< unwrap_reference< T > >, function< T >, pmf< T >, pmd< T >, default_callable_traits< T >)::traits traits
Definition: traits.hpp:25
constexpr BOOST_CLBL_TRAITS_INLINE_VAR bool is_transaction_safe_v
typename detail::traits< detail::shallow_decay< T > >::is_transaction_safe type