in_place_factory.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2003, Fernando Luis Cacciola Carballal.
00002 //
00003 // Use, modification, and distribution is subject to the Boost Software
00004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00005 // http://www.boost.org/LICENSE_1_0.txt)
00006 //
00007 // See http://www.boost.org/lib/optional for documentation.
00008 //
00009 // You are welcome to contact the author at:
00010 //  fernando_cacciola@hotmail.com
00011 //
00012 #ifndef BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
00013 #define BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
00014 
00015 #include <sysc/packages/boost/utility/detail/in_place_factory_prefix.hpp>
00016 
00017 #include <sysc/packages/boost/type.hpp>
00018 
00019 namespace boost {
00020 
00021 class in_place_factory_base {} ;
00022 
00023 #define BOOST_DEFINE_INPLACE_FACTORY_CLASS(z,n,_) \
00024 template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
00025 class BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) : public in_place_factory_base \
00026 { \
00027 public: \
00028 \
00029   BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \
00030     : \
00031     BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \
00032   {} \
00033 \
00034   template<class T> \
00035   void apply ( void* address BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) ) const \
00036   { \
00037     new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
00038   } \
00039 \
00040   BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
00041 } ; \
00042 \
00043 template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
00044 BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
00045 in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
00046 { \
00047   return BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
00048            ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
00049 } ; \
00050 
00051 BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
00052 
00053 } // namespace boost
00054 
00055 #include <sysc/packages/boost/utility/detail/in_place_factory_suffix.hpp>
00056 
00057 #endif
00058 

Generated on Wed Jan 21 15:32:10 2009 for SystemC by  doxygen 1.5.5