| 1 | // Copyright (C) 2003, Fernando Luis Cacciola Carballal. |
|---|
| 2 | // |
|---|
| 3 | // Use, modification, and distribution is 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 | // See http://www.boost.org/lib/optional for documentation. |
|---|
| 8 | // |
|---|
| 9 | // You are welcome to contact the author at: |
|---|
| 10 | // fernando_cacciola@hotmail.com |
|---|
| 11 | // |
|---|
| 12 | #ifndef BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP |
|---|
| 13 | #define BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP |
|---|
| 14 | |
|---|
| 15 | #include <boost/utility/detail/in_place_factory_prefix.hpp> |
|---|
| 16 | |
|---|
| 17 | #include <boost/type.hpp> |
|---|
| 18 | |
|---|
| 19 | namespace boost { |
|---|
| 20 | |
|---|
| 21 | class in_place_factory_base {} ; |
|---|
| 22 | |
|---|
| 23 | #define BOOST_DEFINE_INPLACE_FACTORY_CLASS(z,n,_) \ |
|---|
| 24 | template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \ |
|---|
| 25 | class BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) : public in_place_factory_base \ |
|---|
| 26 | { \ |
|---|
| 27 | public: \ |
|---|
| 28 | \ |
|---|
| 29 | BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \ |
|---|
| 30 | : \ |
|---|
| 31 | BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \ |
|---|
| 32 | {} \ |
|---|
| 33 | \ |
|---|
| 34 | template<class T> \ |
|---|
| 35 | void apply ( void* address BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) ) const \ |
|---|
| 36 | { \ |
|---|
| 37 | new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \ |
|---|
| 38 | } \ |
|---|
| 39 | \ |
|---|
| 40 | BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \ |
|---|
| 41 | } ; \ |
|---|
| 42 | \ |
|---|
| 43 | template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \ |
|---|
| 44 | BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \ |
|---|
| 45 | in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \ |
|---|
| 46 | { \ |
|---|
| 47 | return BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \ |
|---|
| 48 | ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \ |
|---|
| 49 | } ; \ |
|---|
| 50 | |
|---|
| 51 | BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() ) |
|---|
| 52 | |
|---|
| 53 | } // namespace boost |
|---|
| 54 | |
|---|
| 55 | #include <boost/utility/detail/in_place_factory_suffix.hpp> |
|---|
| 56 | |
|---|
| 57 | #endif |
|---|
| 58 | |
|---|