return_type.cpp 872 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  8. int main(){ return 0; }
  9. #else
  10. //[ return_type
  11. #include <type_traits>
  12. #include <boost/callable_traits.hpp>
  13. namespace ct = boost::callable_traits;
  14. using expect = int;
  15. struct foo;
  16. template<typename T>
  17. void test() {
  18. using result = ct::return_type_t<T>;
  19. static_assert(std::is_same<expect, result>{}, "");
  20. }
  21. int main() {
  22. test<int()>();
  23. test<int(*)()>();
  24. test<int(&)()>();
  25. test<int() const>();
  26. test<int(foo::*)() const>();
  27. auto x = []() -> int { return 0; };
  28. test<decltype(x)>();
  29. }
  30. //]
  31. #endif //#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS