Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:30

0001 // Copyright (C) 2003, Fernando Luis Cacciola Carballal.
0002 // Copyright (C) 2007, Tobias Schwinger.
0003 //
0004 // Use, modification, and distribution is subject to the Boost Software
0005 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // See http://www.boost.org/libs/optional for documentation.
0009 //
0010 // You are welcome to contact the author at:
0011 //  fernando_cacciola@hotmail.com
0012 //
0013 #ifndef BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
0014 #ifndef BOOST_PP_IS_ITERATING
0015 
0016 #include <boost/utility/detail/in_place_factory_prefix.hpp>
0017 
0018 namespace boost {
0019 
0020 class in_place_factory_base {} ;
0021 
0022 #ifndef BOOST_UTILITY_DOCS
0023 #define  BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY)
0024 #define  BOOST_PP_FILENAME_1 <boost/utility/in_place_factory.hpp>
0025 #endif // BOOST_UTILITY_DOCS
0026 
0027 #include BOOST_PP_ITERATE()
0028 
0029 } // namespace boost
0030 
0031 #include <boost/utility/detail/in_place_factory_suffix.hpp>
0032 
0033 #ifndef BOOST_UTILITY_DOCS
0034 #define BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
0035 #endif
0036 
0037 #else
0038 #define N BOOST_PP_ITERATION()
0039 
0040 #if N
0041 template< BOOST_PP_ENUM_PARAMS(N, class A) >
0042 #endif
0043 class BOOST_PP_CAT(in_place_factory,N)
0044   : 
0045   public in_place_factory_base
0046 {
0047 public:
0048 
0049   explicit BOOST_PP_CAT(in_place_factory,N)
0050       ( BOOST_PP_ENUM_BINARY_PARAMS(N,A,const& a) )
0051 #if N > 0
0052     : BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _)
0053 #endif
0054   {}
0055 
0056   template<class T>
0057   void* apply(void* address) const
0058   {
0059     return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
0060   }
0061 
0062   template<class T>
0063   void* apply(void* address, std::size_t n) const
0064   {
0065     for(char* next = address = this->BOOST_NESTED_TEMPLATE apply<T>(address);
0066         !! --n;)
0067       this->BOOST_NESTED_TEMPLATE apply<T>(next = next+sizeof(T));
0068     return address; 
0069   }
0070 
0071   BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _)
0072 };
0073 
0074 #if N > 0
0075 template< BOOST_PP_ENUM_PARAMS(N, class A) >
0076 inline BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
0077 in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
0078 {
0079   return BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
0080       ( BOOST_PP_ENUM_PARAMS(N, a) );
0081 }
0082 #else
0083 inline in_place_factory0 in_place()
0084 {
0085   return in_place_factory0();
0086 }
0087 #endif
0088 
0089 #undef N
0090 #endif
0091 #endif
0092