add_noexcept.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_NOEXCEPT_TYPES
  8. int main(){}
  9. #else
  10. #include <boost/callable_traits/add_noexcept.hpp>
  11. #include "test.hpp"
  12. template<typename Noexcept, typename NotNoexcept>
  13. void test() {
  14. CT_ASSERT(std::is_same<Noexcept, TRAIT(add_noexcept, NotNoexcept)>::value);
  15. //sanity check
  16. CT_ASSERT(!std::is_same<Noexcept, NotNoexcept>::value);
  17. }
  18. #define TEST_NOEXCEPT(not_noexcept) test<not_noexcept noexcept, not_noexcept>()
  19. int main() {
  20. TEST_NOEXCEPT(int(int) &);
  21. TEST_NOEXCEPT(int(*)(int));
  22. TEST_NOEXCEPT(int(int, ...) &&);
  23. TEST_NOEXCEPT(int(*)(int, ...));
  24. struct foo;
  25. TEST_NOEXCEPT(int(foo::*)(int));
  26. TEST_NOEXCEPT(int(foo::*)(int) const);
  27. TEST_NOEXCEPT(int(foo::*)(int, ...));
  28. TEST_NOEXCEPT(int(foo::*)(int, ...) volatile);
  29. }
  30. #endif // #ifndef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES