remove_noexcept_constraints.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. Copyright Barrett Adair 2016-2017
  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/remove_noexcept.hpp>
  7. #include <tuple>
  8. #include "test.hpp"
  9. #ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
  10. int main(){}
  11. #else
  12. template<typename T>
  13. struct is_substitution_failure_remove_noexcept {
  14. template<typename>
  15. static auto test(...) -> std::true_type;
  16. template<typename A,
  17. typename std::remove_reference<
  18. TRAIT(remove_noexcept, A)>::type* = nullptr>
  19. static auto test(int) -> std::false_type;
  20. static constexpr bool value = decltype(test<T>(0))::value;
  21. };
  22. struct foo;
  23. int main() {
  24. auto lambda = [](){};
  25. CT_ASSERT(is_substitution_failure_remove_noexcept<decltype(lambda)>::value);
  26. CT_ASSERT(is_substitution_failure_remove_noexcept<decltype(lambda)&>::value);
  27. CT_ASSERT(is_substitution_failure_remove_noexcept<int>::value);
  28. CT_ASSERT(is_substitution_failure_remove_noexcept<int &>::value);
  29. CT_ASSERT(is_substitution_failure_remove_noexcept<int (* const &)()>::value);
  30. CT_ASSERT(is_substitution_failure_remove_noexcept<int (foo::* &)()>::value);
  31. CT_ASSERT(is_substitution_failure_remove_noexcept<int (foo::* const)()>::value);
  32. CT_ASSERT(is_substitution_failure_remove_noexcept<int (foo::* const &)()>::value);
  33. CT_ASSERT(is_substitution_failure_remove_noexcept<int (foo::* volatile)()>::value);
  34. CT_ASSERT(is_substitution_failure_remove_noexcept<void>::value);
  35. CT_ASSERT(is_substitution_failure_remove_noexcept<void*>::value);
  36. CT_ASSERT(is_substitution_failure_remove_noexcept<void(**)()>::value);
  37. }
  38. #endif //#ifndef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE