Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-04-04 11:15:21


...and here comes the forgotten attachment ;-|

Regards,
Tobias


? inplace_full.patch
? inplace_make_editable.patch
Index: in_place_factory.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/utility/in_place_factory.hpp,v
retrieving revision 1.6
diff -u -r1.6 in_place_factory.hpp
--- in_place_factory.hpp 23 Sep 2004 17:03:54 -0000 1.6
+++ in_place_factory.hpp 4 Apr 2007 14:56:14 -0000
@@ -1,4 +1,5 @@
 // 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
@@ -9,50 +10,78 @@
 // You are welcome to contact the author at:
 // fernando_cacciola_at_[hidden]
 //
-#ifndef BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
-#define BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
+#ifndef BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
+#ifndef BOOST_PP_IS_ITERATING
 
 #include <boost/utility/detail/in_place_factory_prefix.hpp>
 
-#include <boost/type.hpp>
-
 namespace boost {
 
 class in_place_factory_base {} ;
 
-#define BOOST_DEFINE_INPLACE_FACTORY_CLASS(z,n,_) \
-template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
-class BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) : public in_place_factory_base \
-{ \
-public: \
-\
- BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \
- : \
- BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \
- {} \
-\
- template<class T> \
- void apply ( void* address BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) ) const \
- { \
- new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
- } \
-\
- BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
-} ; \
-\
-template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
-BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
-in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
-{ \
- return BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
- ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
-} ; \
-
-BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
+#define BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY)
+#define BOOST_PP_FILENAME_1 <boost/utility/in_place_factory.hpp>
+#include BOOST_PP_ITERATE()
 
 } // namespace boost
 
 #include <boost/utility/detail/in_place_factory_suffix.hpp>
 
+#define BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
+#else
+#define N BOOST_PP_ITERATION()
+
+#if N
+template< BOOST_PP_ENUM_PARAMS(N, class A) >
+#endif
+class BOOST_PP_CAT(in_place_factory,N)
+ :
+ public in_place_factory_base
+{
+public:
+
+ explicit BOOST_PP_CAT(in_place_factory,N)
+ ( BOOST_PP_ENUM_BINARY_PARAMS(N,A,const& a) )
+#if N > 0
+ : BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _)
+#endif
+ {}
+
+ template<class T>
+ void* apply(void* address
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
+ {
+ return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
+ }
+
+ template<class T>
+ void* apply(void* address, std::size_t n
+ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
+ {
+ for(char* next = address = this->template apply<T>(address); !! --n;)
+ this->template apply<T>(next = next+sizeof(T));
+ return address;
+ }
+
+ BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _)
+};
+
+#if N > 0
+template< BOOST_PP_ENUM_PARAMS(N, class A) >
+inline BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
+in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
+{
+ return BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
+ ( BOOST_PP_ENUM_PARAMS(N, a) );
+}
+#else
+inline in_place_factory0 in_place()
+{
+ return in_place_factory0();
+}
+#endif
+
+#undef N
+#endif
 #endif
 
Index: typed_in_place_factory.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/utility/typed_in_place_factory.hpp,v
retrieving revision 1.5
diff -u -r1.5 typed_in_place_factory.hpp
--- typed_in_place_factory.hpp 23 Sep 2004 17:03:54 -0000 1.5
+++ typed_in_place_factory.hpp 4 Apr 2007 14:56:14 -0000
@@ -1,4 +1,5 @@
 // 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
@@ -9,8 +10,8 @@
 // You are welcome to contact the author at:
 // fernando_cacciola_at_[hidden]
 //
-#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
-#define BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
+#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_04APR2007_HPP
+#ifndef BOOST_PP_IS_ITERATING
 
 #include <boost/utility/detail/in_place_factory_prefix.hpp>
 
@@ -18,40 +19,59 @@
 
 class typed_in_place_factory_base {} ;
 
-#define BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS(z,n,_) \
-template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
-class BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) : public typed_in_place_factory_base \
-{ \
-public: \
-\
- typedef T value_type ; \
-\
- BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \
- : \
- BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \
- {} \
-\
- void apply ( void* address ) const \
- { \
- new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
- } \
-\
- BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
-} ; \
-\
-template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
-BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T , BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
-in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
-{ \
- return BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T, BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
- ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
-} ; \
-
-BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
+#define BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY)
+#define BOOST_PP_FILENAME_1 <boost/utility/typed_in_place_factory.hpp>
+#include BOOST_PP_ITERATE()
 
 } // namespace boost
 
 #include <boost/utility/detail/in_place_factory_suffix.hpp>
 
+#define BOOST_UTILITY_TYPED_INPLACE_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_in_place_factory,N)
+ :
+ public typed_in_place_factory_base
+{
+public:
+
+ typedef T value_type;
+
+ explicit BOOST_PP_CAT(typed_in_place_factory,N)
+ ( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
+#if N > 0
+ : BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _)
+#endif
+ {}
+
+ void* apply (void* address) const
+ {
+ return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
+ }
+
+ void* apply (void* address, std::size_t n) const
+ {
+ for(char* next = address = this->apply(address); !! --n;)
+ this->apply(next = next+sizeof(T));
+ return address;
+ }
+
+ BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _)
+};
+
+template< class T BOOST_PP_ENUM_TRAILING_PARAMS(N, class A) >
+inline BOOST_PP_CAT(typed_in_place_factory,N)<
+ T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) >
+in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
+{
+ return BOOST_PP_CAT(typed_in_place_factory,N)<
+ T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) >( BOOST_PP_ENUM_PARAMS(N, a) );
+}
+
+#undef N
+#endif
 #endif
 
Index: detail/in_place_factory_prefix.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/utility/detail/in_place_factory_prefix.hpp,v
retrieving revision 1.1
diff -u -r1.1 in_place_factory_prefix.hpp
--- detail/in_place_factory_prefix.hpp 21 Sep 2004 14:54:32 -0000 1.1
+++ detail/in_place_factory_prefix.hpp 4 Apr 2007 14:56:14 -0000
@@ -1,4 +1,5 @@
 // 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
@@ -9,25 +10,27 @@
 // You are welcome to contact the author at:
 // fernando_cacciola_at_[hidden]
 //
-#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
-#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
+#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP
+#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP
 
+#include <new>
+#include <cstddef>
 #include <boost/config.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/punctuation/paren.hpp>
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
 #include <boost/preprocessor/repetition/enum.hpp>
 #include <boost/preprocessor/repetition/enum_params.hpp>
 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
-#include <boost/preprocessor/cat.hpp>
-#include <boost/preprocessor/arithmetic/inc.hpp>
-#include <boost/preprocessor/punctuation/paren.hpp>
-#include <boost/preprocessor/facilities/empty.hpp>
+#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
 
 #define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT(z,n,_) BOOST_PP_CAT(m_a,n) BOOST_PP_LPAREN() BOOST_PP_CAT(a,n) BOOST_PP_RPAREN()
 #define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL(z,n,_) BOOST_PP_CAT(A,n) const& BOOST_PP_CAT(m_a,n);
-#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG(z,n,_) BOOST_PP_CAT(m_a,n)
 
 #define BOOST_MAX_INPLACE_FACTORY_ARITY 10
 
-#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
+#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP
 
 #endif
 
Index: detail/in_place_factory_suffix.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/utility/detail/in_place_factory_suffix.hpp,v
retrieving revision 1.1
diff -u -r1.1 in_place_factory_suffix.hpp
--- detail/in_place_factory_suffix.hpp 21 Sep 2004 14:54:32 -0000 1.1
+++ detail/in_place_factory_suffix.hpp 4 Apr 2007 14:56:14 -0000
@@ -1,4 +1,5 @@
 // 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
@@ -9,15 +10,14 @@
 // You are welcome to contact the author at:
 // fernando_cacciola_at_[hidden]
 //
-#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
-#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
+#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP
+#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP
 
 #undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT
 #undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL
-#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG
 #undef BOOST_MAX_INPLACE_FACTORY_ARITY
 
-#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
+#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP
 
 #endif
 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk