args.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. //[ args
  11. #include <type_traits>
  12. #include <memory>
  13. #include <boost/callable_traits.hpp>
  14. namespace ct = boost::callable_traits;
  15. template<typename T, typename Expect>
  16. void test(){
  17. using args_t = ct::args_t<T>;
  18. static_assert(std::is_same<args_t, Expect>::value, "");
  19. }
  20. int main() {
  21. {
  22. auto lamda = [](int, float&, const char*){};
  23. using lam = decltype(lamda);
  24. using expect = std::tuple<int, float&, const char*>;
  25. test<lam, expect>();
  26. }
  27. {
  28. struct foo;
  29. using pmf = void(foo::*)(int, float&, const char*);
  30. using expect = std::tuple<foo&, int, float&, const char*>;
  31. test<pmf, expect>();
  32. }
  33. {
  34. using function_ptr = void(*)(int, float&, const char*);
  35. using expect = std::tuple<int, float&, const char*>;
  36. test<function_ptr, expect>();
  37. }
  38. {
  39. using function_ref = void(&)(int, float&, const char*);
  40. using expect = std::tuple<int, float&, const char*>;
  41. test<function_ref, expect>();
  42. }
  43. {
  44. using function = void(int, float&, const char*);
  45. using expect = std::tuple<int, float&, const char*>;
  46. test<function, expect>();
  47. }
  48. {
  49. using abominable = void(int, float&, const char*) const;
  50. using expect = std::tuple<int, float&, const char*>;
  51. test<abominable, expect>();
  52. }
  53. }
  54. //]
  55. #endif //#ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS