variadic_function_synthesis.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // (C) Copyright Tobias Schwinger
  2. //
  3. // Use modification and distribution are subject to the boost Software License,
  4. // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
  5. //------------------------------------------------------------------------------
  6. #include <boost/mpl/assert.hpp>
  7. #include <boost/mpl/vector.hpp>
  8. #include <boost/type_traits/is_same.hpp>
  9. #include <boost/function_types/function_type.hpp>
  10. #include <boost/function_types/function_pointer.hpp>
  11. #include <boost/function_types/function_reference.hpp>
  12. #include <boost/function_types/member_function_pointer.hpp>
  13. namespace ft = boost::function_types;
  14. namespace mpl = boost::mpl;
  15. using boost::is_same;
  16. class C;
  17. typedef int expected_v_1(...);
  18. typedef int expected_nv_1();
  19. typedef int (C::*expected_v_2)(...);
  20. typedef int (C::*expected_nv_2)();
  21. BOOST_MPL_ASSERT(( is_same<
  22. ft::function_type<mpl::vector<int>, ft::variadic>::type, expected_v_1
  23. > ));
  24. BOOST_MPL_ASSERT(( is_same<
  25. ft::function_type<mpl::vector<int>, ft::non_variadic>::type, expected_nv_1
  26. > ));
  27. BOOST_MPL_ASSERT(( is_same<
  28. ft::function_pointer<mpl::vector<int>, ft::variadic>::type, expected_v_1 *
  29. > ));
  30. BOOST_MPL_ASSERT(( is_same<
  31. ft::function_pointer<mpl::vector<int>, ft::non_variadic>::type
  32. , expected_nv_1 *
  33. > ));
  34. BOOST_MPL_ASSERT(( is_same<
  35. ft::function_reference<mpl::vector<int>, ft::variadic>::type, expected_v_1 &
  36. > ));
  37. BOOST_MPL_ASSERT(( is_same<
  38. ft::function_reference<mpl::vector<int>, ft::non_variadic>::type
  39. , expected_nv_1 &
  40. > ));
  41. BOOST_MPL_ASSERT(( is_same<
  42. ft::member_function_pointer<mpl::vector<int,C>, ft::variadic>::type
  43. , expected_v_2
  44. > ));
  45. BOOST_MPL_ASSERT(( is_same<
  46. ft::member_function_pointer<mpl::vector<int,C>, ft::non_variadic>::type
  47. , expected_nv_2
  48. > ));