/Src/Dependencies/Boost/boost/spirit/home/phoenix/bind/detail/function_ptr.hpp

http://hadesmem.googlecode.com/ · C++ Header · 99 lines · 69 code · 19 blank · 11 comment · 0 complexity · f34d453dcba4ec90dac0c4bf8f33c130 MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(BOOST_PP_IS_ITERATING)
  7. #if !defined(PHOENIX_BIND_DETAIL_FUNCTION_PTR_HPP)
  8. #define PHOENIX_BIND_DETAIL_FUNCTION_PTR_HPP
  9. #include <boost/preprocessor/iterate.hpp>
  10. #include <boost/preprocessor/repetition/enum_params.hpp>
  11. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  12. #include <boost/preprocessor/dec.hpp>
  13. namespace boost { namespace phoenix { namespace detail
  14. {
  15. template <int N>
  16. struct function_ptr_impl
  17. {
  18. template <typename RT, typename FP>
  19. struct impl;
  20. };
  21. template <int N, typename RT, typename FP>
  22. struct function_ptr : function_ptr_impl<N>::template impl<RT, FP>
  23. {
  24. typedef typename function_ptr_impl<N>::template impl<RT, FP> base;
  25. function_ptr(FP fp)
  26. : base(fp) {}
  27. };
  28. template <>
  29. struct function_ptr_impl<0>
  30. {
  31. template <typename RT, typename FP>
  32. struct impl
  33. {
  34. typedef RT result_type;
  35. impl(FP fp)
  36. : fp(fp) {}
  37. RT operator()() const
  38. {
  39. return fp();
  40. }
  41. FP fp;
  42. };
  43. };
  44. #define BOOST_PP_ITERATION_PARAMS_1 \
  45. (3, (1, PHOENIX_COMPOSITE_LIMIT, \
  46. "boost/spirit/home/phoenix/bind/detail/function_ptr.hpp"))
  47. #include BOOST_PP_ITERATE()
  48. }}} // namespace boost::phoenix::detail
  49. #endif
  50. ///////////////////////////////////////////////////////////////////////////////
  51. //
  52. // Preprocessor vertical repetition code
  53. //
  54. ///////////////////////////////////////////////////////////////////////////////
  55. #else // defined(BOOST_PP_IS_ITERATING)
  56. #define N BOOST_PP_ITERATION()
  57. template <>
  58. struct function_ptr_impl<N>
  59. {
  60. template <typename RT, typename FP>
  61. struct impl
  62. {
  63. template <BOOST_PP_ENUM_PARAMS(N, typename T)>
  64. struct result
  65. {
  66. typedef RT type;
  67. };
  68. impl(FP fp)
  69. : fp(fp) {}
  70. template <BOOST_PP_ENUM_PARAMS(N, typename A)>
  71. RT operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, & _)) const
  72. {
  73. return fp(BOOST_PP_ENUM_PARAMS(N, _));
  74. }
  75. FP fp;
  76. };
  77. };
  78. #undef N
  79. #endif // defined(BOOST_PP_IS_ITERATING)