add_transaction_safe.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/detail/config.hpp>
  7. #ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
  8. int main(){}
  9. #else
  10. #include <boost/callable_traits/add_transaction_safe.hpp>
  11. #include "test.hpp"
  12. template<typename Safe, typename NotSafe>
  13. void test() {
  14. CT_ASSERT(std::is_same<Safe, TRAIT(add_transaction_safe, NotSafe)>::value);
  15. //sanity check
  16. CT_ASSERT(!std::is_same<Safe, NotSafe>::value);
  17. }
  18. #define TEST_TRANSACTION_SAFE(not_safe) test<not_safe transaction_safe, not_safe>()
  19. int main() {
  20. TEST_TRANSACTION_SAFE(int(int) &);
  21. TEST_TRANSACTION_SAFE(int(*)(int));
  22. TEST_TRANSACTION_SAFE(int(int, ...) &&);
  23. TEST_TRANSACTION_SAFE(int(*)(int, ...));
  24. struct foo;
  25. TEST_TRANSACTION_SAFE(int(foo::*)(int));
  26. TEST_TRANSACTION_SAFE(int(foo::*)(int) const);
  27. TEST_TRANSACTION_SAFE(int(foo::*)(int, ...));
  28. TEST_TRANSACTION_SAFE(int(foo::*)(int, ...) volatile);
  29. }
  30. #endif