// Copyright (C) 2003, Fernando Luis Cacciola Carballal. // Copyright (C) 2007, Tobias Schwinger. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/lib/optional for documentation. // // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // #ifndef BOOST_UTILITY_TYPED_OUTOFPLACE_FACTORY_04APR2007_HPP #ifndef BOOST_PP_IS_ITERATING #include #include namespace boost { #define BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY) #define BOOST_PP_FILENAME_1 #include BOOST_PP_ITERATE() } // namespace boost #include #define BOOST_UTILITY_TYPED_OUTOFPLACE_FACTORY_04APR2007_HPP #else #define N BOOST_PP_ITERATION() template< class T BOOST_PP_ENUM_TRAILING_PARAMS(N,class A) > class BOOST_PP_CAT(typed_out_of_place_factory,N) : public BOOST_PP_CAT(typed_in_place_factory,N) < T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) > { typedef BOOST_PP_CAT(typed_in_place_factory,N) < T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) > base_type; public: typedef T value_type; explicit BOOST_PP_CAT(typed_out_of_place_factory,N) ( base_type const & b ) : base_type(b) {} void* apply () const { return new T( BOOST_PP_ENUM_PARAMS(N, this->m_a) ); } void* apply (std::size_t n) const { return new T[n]( BOOST_PP_ENUM_PARAMS(N, this->m_a) ); } }; template< class T BOOST_PP_ENUM_TRAILING_PARAMS(N, class A) > inline BOOST_PP_CAT(typed_out_of_place_factory,N)< T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) > out_of_place( BOOST_PP_CAT(typed_in_place_factory,N)< T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) > const & b) { return BOOST_PP_CAT(typed_out_of_place_factory,N)< T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) > (b); } #undef N #endif #endif