poly_function_traits.hpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/detail/preprocessed/poly_function_traits.hpp>
  3. #elif !defined(BOOST_PP_IS_ITERATING)
  4. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  5. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/poly_function_traits.hpp")
  6. #endif
  7. ///////////////////////////////////////////////////////////////////////////////
  8. // poly_function_traits.hpp
  9. // Contains specializations of poly_function_traits and as_mono_function
  10. //
  11. // Copyright 2008 Eric Niebler. Distributed under the Boost
  12. // Software License, Version 1.0. (See accompanying file
  13. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  14. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  15. #pragma wave option(preserve: 1)
  16. #endif
  17. #define BOOST_PP_ITERATION_PARAMS_1 \
  18. (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/poly_function_traits.hpp>))
  19. #include BOOST_PP_ITERATE()
  20. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  21. #pragma wave option(output: null)
  22. #endif
  23. #else
  24. #define N BOOST_PP_ITERATION()
  25. ////////////////////////////////////////////////////////////////////////////////////////////////
  26. template<typename PolyFun BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  27. struct poly_function_traits<PolyFun, PolyFun(BOOST_PP_ENUM_PARAMS(N, A)), mpl::size_t<sizeof(poly_function_t)> >
  28. {
  29. typedef typename PolyFun::template impl<BOOST_PP_ENUM_PARAMS(N, const A)> function_type;
  30. typedef typename function_type::result_type result_type;
  31. };
  32. ////////////////////////////////////////////////////////////////////////////////////////////////
  33. template<typename PolyFun BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  34. struct as_mono_function_impl<PolyFun(BOOST_PP_ENUM_PARAMS(N, A)), true>
  35. {
  36. typedef typename PolyFun::template impl<BOOST_PP_ENUM_PARAMS(N, const A)> type;
  37. };
  38. ////////////////////////////////////////////////////////////////////////////////////////////////
  39. template<typename PolyFun BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  40. struct as_mono_function_impl<PolyFun(BOOST_PP_ENUM_PARAMS(N, A)), false>
  41. {
  42. typedef PolyFun type;
  43. };
  44. ////////////////////////////////////////////////////////////////////////////////////////////////
  45. template<typename PolyFun BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  46. struct as_mono_function<PolyFun(BOOST_PP_ENUM_PARAMS(N, A))>
  47. : as_mono_function_impl<PolyFun(BOOST_PP_ENUM_PARAMS(N, A)), is_poly_function<PolyFun>::value>
  48. {};
  49. #undef N
  50. #endif // BOOST_PROTO_DONT_USE_PREPROCESSED_FILES