is_transaction_safe.hpp 2.9 KB

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