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