is_transaction_safe.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*<-
  2. Copyright (c) 2016 Barrett Adair
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  5. ->*/
  6. #include <boost/callable_traits/is_transaction_safe.hpp>
  7. #include "test.hpp"
  8. template<typename Safe, typename NotSafe>
  9. void test() {
  10. CT_ASSERT( is_transaction_safe<Safe>::value
  11. // for when tx safe is disabled
  12. || std::is_same<Safe, NotSafe>::value);
  13. CT_ASSERT(! is_transaction_safe<NotSafe>::value);
  14. }
  15. #define TEST_TRANSACTION_SAFE(not_safe) \
  16. test<not_safe BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER, not_safe>()
  17. int main() {
  18. TEST_TRANSACTION_SAFE(int(*)());
  19. #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  20. TEST_TRANSACTION_SAFE(int(...) volatile LREF);
  21. TEST_TRANSACTION_SAFE(int() const);
  22. #endif
  23. TEST_TRANSACTION_SAFE(int(*)(...));
  24. struct foo;
  25. TEST_TRANSACTION_SAFE(int(foo::*)());
  26. TEST_TRANSACTION_SAFE(int(foo::*)() const volatile);
  27. TEST_TRANSACTION_SAFE(int(foo::*)(...));
  28. TEST_TRANSACTION_SAFE(int(foo::*)(...) const volatile RREF);
  29. }