register_functions_iterate.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Copyright (C) 2004 Arkadiy Vertleyb
  2. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include <boost/typeof/encode_decode_params.hpp>
  5. #define n BOOST_PP_ITERATION()
  6. // function pointers
  7. template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
  8. struct encode_type_impl<V, R(*)(BOOST_PP_ENUM_PARAMS(n, P))>
  9. {
  10. typedef R BOOST_PP_CAT(P, n);
  11. typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_PTR_ID + n) type;
  12. };
  13. template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
  14. struct encode_type_impl<V, R(*)(BOOST_PP_ENUM_PARAMS(n, P) ...)>
  15. {
  16. typedef R BOOST_PP_CAT(P, n);
  17. typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_PTR_ID + n) type;
  18. };
  19. template<class Iter>
  20. struct decode_type_impl<boost::type_of::constant<std::size_t,FUN_PTR_ID + n>, Iter>
  21. {
  22. typedef Iter iter0;
  23. BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
  24. typedef BOOST_PP_CAT(p, n)(*type)(BOOST_PP_ENUM_PARAMS(n, p));
  25. typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
  26. };
  27. template<class Iter>
  28. struct decode_type_impl<boost::type_of::constant<std::size_t,FUN_VAR_PTR_ID + n>, Iter>
  29. {
  30. typedef Iter iter0;
  31. BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
  32. typedef BOOST_PP_CAT(p, n)(*type)(BOOST_PP_ENUM_PARAMS(n, p) ...);
  33. typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
  34. };
  35. #ifndef BOOST_TYPEOF_NO_FUNCTION_TYPES
  36. // function references
  37. template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
  38. struct encode_type_impl<V, R(&)(BOOST_PP_ENUM_PARAMS(n, P))>
  39. {
  40. typedef R BOOST_PP_CAT(P, n);
  41. typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_REF_ID + n) type;
  42. };
  43. template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
  44. struct encode_type_impl<V, R(&)(BOOST_PP_ENUM_PARAMS(n, P) ...)>
  45. {
  46. typedef R BOOST_PP_CAT(P, n);
  47. typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_REF_ID + n) type;
  48. };
  49. template<class Iter>
  50. struct decode_type_impl<boost::type_of::constant<std::size_t,FUN_REF_ID + n>, Iter>
  51. {
  52. typedef Iter iter0;
  53. BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
  54. typedef BOOST_PP_CAT(p, n)(&type)(BOOST_PP_ENUM_PARAMS(n, p));
  55. typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
  56. };
  57. template<class Iter>
  58. struct decode_type_impl<boost::type_of::constant<std::size_t,FUN_VAR_REF_ID + n>, Iter>
  59. {
  60. typedef Iter iter0;
  61. BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
  62. typedef BOOST_PP_CAT(p, n)(&type)(BOOST_PP_ENUM_PARAMS(n, p) ...);
  63. typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
  64. };
  65. // functions
  66. template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
  67. struct encode_type_impl<V, R(BOOST_PP_ENUM_PARAMS(n, P))>
  68. {
  69. typedef R BOOST_PP_CAT(P, n);
  70. typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_ID + n) type;
  71. };
  72. template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
  73. struct encode_type_impl<V, R(BOOST_PP_ENUM_PARAMS(n, P) ...)>
  74. {
  75. typedef R BOOST_PP_CAT(P, n);
  76. typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_ID + n) type;
  77. };
  78. template<class Iter>
  79. struct decode_type_impl<boost::type_of::constant<std::size_t,FUN_ID + n>, Iter>
  80. {
  81. typedef Iter iter0;
  82. BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
  83. typedef BOOST_PP_CAT(p, n)(type)(BOOST_PP_ENUM_PARAMS(n, p));
  84. typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
  85. };
  86. template<class Iter>
  87. struct decode_type_impl<boost::type_of::constant<std::size_t,FUN_VAR_ID + n>, Iter>
  88. {
  89. typedef Iter iter0;
  90. BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
  91. typedef BOOST_PP_CAT(p, n)(type)(BOOST_PP_ENUM_PARAMS(n, p) ...);
  92. typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
  93. };
  94. #endif//BOOST_TYPEOF_NO_FUNCTION_TYPES
  95. #ifndef BOOST_TYPEOF_NO_MEMBER_FUNCTION_TYPES
  96. // member functions
  97. #define BOOST_TYPEOF_qualifier
  98. #define BOOST_TYPEOF_id MEM_FUN_ID
  99. #include <boost/typeof/register_mem_functions.hpp>
  100. #define BOOST_TYPEOF_qualifier const
  101. #define BOOST_TYPEOF_id CONST_MEM_FUN_ID
  102. #include <boost/typeof/register_mem_functions.hpp>
  103. #define BOOST_TYPEOF_qualifier volatile
  104. #define BOOST_TYPEOF_id VOLATILE_MEM_FUN_ID
  105. #include <boost/typeof/register_mem_functions.hpp>
  106. #define BOOST_TYPEOF_qualifier volatile const
  107. #define BOOST_TYPEOF_id VOLATILE_CONST_MEM_FUN_ID
  108. #include <boost/typeof/register_mem_functions.hpp>
  109. #undef n
  110. #endif