typed_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_TYPED_INPLACE_FACTORY_25AGO2003_HPP
00013 #define BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
00014 
00015 #include <sysc/packages/boost/utility/detail/in_place_factory_prefix.hpp>
00016 
00017 namespace boost {
00018 
00019 class typed_in_place_factory_base {} ;
00020 
00021 #define BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS(z,n,_) \
00022 template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
00023 class BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) : public typed_in_place_factory_base \
00024 { \
00025 public: \
00026 \
00027   typedef T value_type ; \
00028 \
00029   BOOST_PP_CAT(typed_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   void apply ( void* address ) const \
00035   { \
00036     new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
00037   } \
00038 \
00039   BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
00040 } ; \
00041 \
00042 template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
00043 BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T , BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
00044 in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
00045 { \
00046   return BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T, BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
00047            ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
00048 } ; \
00049 
00050 BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
00051 
00052 } // namespace boost
00053 
00054 #include <sysc/packages/boost/utility/detail/in_place_factory_suffix.hpp>
00055 
00056 #endif
00057 

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