value_factory.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*=============================================================================
  2. Copyright (c) 2007 Tobias Schwinger
  3. Use modification and distribution are subject to the Boost Software
  4. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. ==============================================================================*/
  7. #ifndef BOOST_FUNCTIONAL_VALUE_FACTORY_HPP_INCLUDED
  8. # ifndef BOOST_PP_IS_ITERATING
  9. # include <boost/preprocessor/iteration/iterate.hpp>
  10. # include <boost/preprocessor/repetition/enum_params.hpp>
  11. # include <boost/preprocessor/repetition/enum_binary_params.hpp>
  12. # include <new>
  13. # include <boost/pointee.hpp>
  14. # include <boost/get_pointer.hpp>
  15. # include <boost/non_type.hpp>
  16. # include <boost/type_traits/remove_cv.hpp>
  17. # ifndef BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY
  18. # define BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY 10
  19. # elif BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY < 3
  20. # undef BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY
  21. # define BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY 3
  22. # endif
  23. namespace boost
  24. {
  25. template< typename T >
  26. class value_factory;
  27. //----- ---- --- -- - - - -
  28. template< typename T >
  29. class value_factory
  30. {
  31. public:
  32. typedef T result_type;
  33. value_factory()
  34. { }
  35. # define BOOST_PP_FILENAME_1 <boost/functional/value_factory.hpp>
  36. # define BOOST_PP_ITERATION_LIMITS (0,BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY)
  37. # include BOOST_PP_ITERATE()
  38. };
  39. template< typename T > class value_factory<T&>;
  40. // forbidden, would create a dangling reference
  41. }
  42. # define BOOST_FUNCTIONAL_VALUE_FACTORY_HPP_INCLUDED
  43. # else // defined(BOOST_PP_IS_ITERATING)
  44. # define N BOOST_PP_ITERATION()
  45. # if N > 0
  46. template< BOOST_PP_ENUM_PARAMS(N, typename T) >
  47. # endif
  48. inline result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const
  49. {
  50. return result_type(BOOST_PP_ENUM_PARAMS(N,a));
  51. }
  52. # undef N
  53. # endif // defined(BOOST_PP_IS_ITERATING)
  54. #endif // include guard