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/none_t.hpp>
  15. # include <boost/get_pointer.hpp>
  16. # include <boost/non_type.hpp>
  17. # include <boost/type_traits/remove_cv.hpp>
  18. # ifndef BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY
  19. # define BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY 10
  20. # elif BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY < 3
  21. # undef BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY
  22. # define BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY 3
  23. # endif
  24. namespace boost
  25. {
  26. template< typename T >
  27. class value_factory;
  28. //----- ---- --- -- - - - -
  29. template< typename T >
  30. class value_factory
  31. {
  32. public:
  33. typedef T result_type;
  34. value_factory()
  35. { }
  36. # define BOOST_PP_FILENAME_1 <boost/functional/value_factory.hpp>
  37. # define BOOST_PP_ITERATION_LIMITS (0,BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY)
  38. # include BOOST_PP_ITERATE()
  39. };
  40. template< typename T > class value_factory<T&>;
  41. // forbidden, would create a dangling reference
  42. }
  43. # define BOOST_FUNCTIONAL_VALUE_FACTORY_HPP_INCLUDED
  44. # else // defined(BOOST_PP_IS_ITERATING)
  45. # define N BOOST_PP_ITERATION()
  46. # if N > 0
  47. template< BOOST_PP_ENUM_PARAMS(N, typename T) >
  48. # endif
  49. inline result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const
  50. {
  51. return result_type(BOOST_PP_ENUM_PARAMS(N,a));
  52. }
  53. # undef N
  54. # endif // defined(BOOST_PP_IS_ITERATING)
  55. #endif // include guard