return_type.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright Barrett Adair 2015-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 <type_traits>
  7. #include <cstdint>
  8. #include <memory>
  9. #include <boost/callable_traits.hpp>
  10. #include "test.hpp"
  11. struct foo1 {
  12. int bar(char, float&, int = 0) { return{}; }
  13. };
  14. struct foo2 {
  15. int bar(char, float&, int = 0, ...) { return{}; }
  16. };
  17. struct foo3 {
  18. int operator()(char, float&, int = 0) { return{}; }
  19. };
  20. struct foo4 {
  21. int operator()(char, float&, int = 0, ...) { return{}; }
  22. };
  23. int foo5(char, float&, int = 0) { return{}; }
  24. int foo6(char, float&, int = 0, ...) { return{}; }
  25. using std::is_same;
  26. int main() {
  27. {
  28. using pmf = decltype(&foo1::bar);
  29. CT_ASSERT(std::is_same< return_type_t<pmf>, int>{});
  30. } {
  31. using pmf = decltype(&foo2::bar);
  32. CT_ASSERT(std::is_same< return_type_t<pmf>, int>{});
  33. } {
  34. CT_ASSERT(std::is_same< return_type_t<foo3>, int>{});
  35. } {
  36. CT_ASSERT(std::is_same< return_type_t<foo4>, int>{});
  37. } {
  38. CT_ASSERT(std::is_same< return_type_t<decltype(foo5)>, int>{});
  39. } {
  40. CT_ASSERT(std::is_same< return_type_t<decltype(foo6)>, int>{});
  41. }
  42. return 0;
  43. }