ossrv_pub/boost_apis/boost/utility/typed_in_place_factory.hpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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_TYPED_INPLACE_FACTORY_25AGO2003_HPP
       
    13 #define BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
       
    14 
       
    15 #include <boost/utility/detail/in_place_factory_prefix.hpp>
       
    16 
       
    17 namespace boost {
       
    18 
       
    19 class typed_in_place_factory_base {} ;
       
    20 
       
    21 #define BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS(z,n,_) \
       
    22 template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
       
    23 class BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) : public typed_in_place_factory_base \
       
    24 { \
       
    25 public: \
       
    26 \
       
    27   typedef T value_type ; \
       
    28 \
       
    29   BOOST_PP_CAT(typed_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   void apply ( void* address ) const \
       
    35   { \
       
    36     new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
       
    37   } \
       
    38 \
       
    39   BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
       
    40 } ; \
       
    41 \
       
    42 template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
       
    43 BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T , BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
       
    44 in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
       
    45 { \
       
    46   return BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T, BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
       
    47            ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
       
    48 } ; \
       
    49 
       
    50 BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
       
    51 
       
    52 } // namespace boost
       
    53 
       
    54 #include <boost/utility/detail/in_place_factory_suffix.hpp>
       
    55 
       
    56 #endif
       
    57