forked from boostorg/utility
		
	Compare commits
	
		
			14 Commits
		
	
	
		
			svn-branch
			...
			boost-1.34
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | ce465c8910 | ||
|  | d5ea07c737 | ||
|  | aa0096bf42 | ||
|  | 005c2f3cc8 | ||
|  | 09f7aab52d | ||
|  | 30a40f9f76 | ||
|  | d9f8bae673 | ||
|  | 3c7b409460 | ||
|  | ee3551e8dc | ||
|  | 95da2e90de | ||
|  | 6dd93ab916 | ||
|  | 505d419a1b | ||
|  | d968b5f5b9 | ||
|  | d809d4e832 | 
| @@ -3,8 +3,9 @@ | ||||
| <HTML> | ||||
|  | ||||
| <HEAD> | ||||
| <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"> | ||||
| <TITLE>In_place_factory Documentation</TITLE> | ||||
| <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> | ||||
| <LINK REL="stylesheet" TYPE="text/css" HREF="../../boost.css"> | ||||
| <TITLE>Header </TITLE> | ||||
| </HEAD> | ||||
|  | ||||
| <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080"> | ||||
| @@ -76,7 +77,7 @@ object is likely to be temporary and serve no purpose besides being the source</ | ||||
| </pre> | ||||
| <p>A solution to this problem is to support direct construction of the contained | ||||
| object right in the container's storage.<br> | ||||
| In this scheme, the user supplies the arguments for the X constructor | ||||
| In this shceme, the user supplies the arguments for the X constructor | ||||
| directly to the container:</p> | ||||
| <pre>struct C | ||||
| { | ||||
| @@ -137,7 +138,7 @@ The following simplified example shows the basic idea. A complete example follow | ||||
|  | ||||
| void foo() | ||||
| { | ||||
|   C c( in_place(123,"hello") ) ; | ||||
|   C c( in_place(123,"hello" ) ; | ||||
| } | ||||
| </pre> | ||||
|  | ||||
|   | ||||
| @@ -32,10 +32,6 @@ inline void current_function_helper() | ||||
|  | ||||
| # define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ | ||||
|  | ||||
| #elif defined(__DMC__) && (__DMC__ >= 0x810) | ||||
|  | ||||
| # define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__ | ||||
|  | ||||
| #elif defined(__FUNCSIG__) | ||||
|  | ||||
| # define BOOST_CURRENT_FUNCTION __FUNCSIG__ | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| // 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 | ||||
| @@ -10,27 +9,25 @@ | ||||
| // You are welcome to contact the author at: | ||||
| //  fernando_cacciola@hotmail.com | ||||
| // | ||||
| #ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP | ||||
| #define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP | ||||
| #ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP | ||||
| #define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_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/repetition/enum_trailing_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> | ||||
|  | ||||
| #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_04APR2007_HPP | ||||
| #undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| // 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 | ||||
| @@ -10,14 +9,15 @@ | ||||
| // You are welcome to contact the author at: | ||||
| //  fernando_cacciola@hotmail.com | ||||
| // | ||||
| #ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP | ||||
| #define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP | ||||
| #ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP | ||||
| #define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_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_04APR2007_HPP | ||||
| #undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -21,69 +21,66 @@ | ||||
| template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) | ||||
|          BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> | ||||
| struct result_of<F(BOOST_RESULT_OF_ARGS)> | ||||
|     : boost::detail::result_of_impl<F, F(BOOST_RESULT_OF_ARGS), (boost::detail::has_result_type<F>::value)> {}; | ||||
|     : detail::result_of<F, F(BOOST_RESULT_OF_ARGS)> {}; | ||||
| #endif | ||||
|  | ||||
| #undef BOOST_RESULT_OF_ARGS | ||||
|  | ||||
| #if BOOST_PP_ITERATION() >= 1  | ||||
|  | ||||
| namespace detail { | ||||
|  | ||||
| template<typename R,  typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) | ||||
|          BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> | ||||
| struct result_of_impl<R (*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false> | ||||
| struct result_of<R (*)(BOOST_RESULT_OF_ARGS), FArgs> | ||||
| { | ||||
|   typedef R type; | ||||
| }; | ||||
|  | ||||
| template<typename R,  typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) | ||||
|          BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> | ||||
| struct result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false> | ||||
| struct result_of<R (&)(BOOST_RESULT_OF_ARGS), FArgs> | ||||
| { | ||||
|   typedef R type; | ||||
| }; | ||||
|  | ||||
| #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) | ||||
| #undef BOOST_RESULT_OF_ARGS | ||||
|  | ||||
| #if BOOST_PP_ITERATION() > 1 && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) | ||||
| template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) | ||||
|          BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> | ||||
| struct result_of_impl<R (T0::*) | ||||
| struct result_of<R (T0::*) | ||||
|                      (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)), | ||||
|                  FArgs, false> | ||||
|                  FArgs> | ||||
| { | ||||
|   typedef R type; | ||||
| }; | ||||
|  | ||||
| template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) | ||||
|          BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> | ||||
| struct result_of_impl<R (T0::*) | ||||
| struct result_of<R (T0::*) | ||||
|                      (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)) | ||||
|                      const, | ||||
|                  FArgs, false> | ||||
|                  FArgs> | ||||
| { | ||||
|   typedef R type; | ||||
| }; | ||||
|  | ||||
| template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) | ||||
|          BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> | ||||
| struct result_of_impl<R (T0::*) | ||||
| struct result_of<R (T0::*) | ||||
|                      (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)) | ||||
|                      volatile, | ||||
|                  FArgs, false> | ||||
|                  FArgs> | ||||
| { | ||||
|   typedef R type; | ||||
| }; | ||||
|  | ||||
| template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION()) | ||||
|          BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> | ||||
| struct result_of_impl<R (T0::*) | ||||
| struct result_of<R (T0::*) | ||||
|                      (BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)) | ||||
|                      const volatile, | ||||
|                  FArgs, false> | ||||
|                  FArgs> | ||||
| { | ||||
|   typedef R type; | ||||
| }; | ||||
| #endif | ||||
|  | ||||
| } | ||||
| #endif | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| // 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 | ||||
| @@ -10,79 +9,50 @@ | ||||
| // You are welcome to contact the author at: | ||||
| //  fernando_cacciola@hotmail.com | ||||
| // | ||||
| #ifndef BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP | ||||
| #ifndef BOOST_PP_IS_ITERATING | ||||
| #ifndef BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP | ||||
| #define BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP | ||||
|  | ||||
| #include <boost/utility/detail/in_place_factory_prefix.hpp> | ||||
|  | ||||
| #include <boost/type.hpp> | ||||
|  | ||||
| namespace boost { | ||||
|  | ||||
| class in_place_factory_base {} ; | ||||
|  | ||||
| #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() | ||||
| #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() ) | ||||
|  | ||||
| } // 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->BOOST_NESTED_TEMPLATE apply<T>(address); | ||||
|         !! --n;) | ||||
|       this->BOOST_NESTED_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 | ||||
|  | ||||
|   | ||||
| @@ -15,8 +15,6 @@ | ||||
| #include <boost/preprocessor.hpp> | ||||
| #include <boost/detail/workaround.hpp> | ||||
| #include <boost/mpl/has_xxx.hpp> | ||||
| #include <boost/mpl/if.hpp> | ||||
| #include <boost/mpl/bool.hpp> | ||||
|  | ||||
| #ifndef BOOST_RESULT_OF_NUM_ARGS | ||||
| #  define BOOST_RESULT_OF_NUM_ARGS 10 | ||||
| @@ -31,48 +29,28 @@ namespace detail { | ||||
|  | ||||
| BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) | ||||
|  | ||||
| template<typename F, typename FArgs, bool HasResultType> struct result_of_impl; | ||||
|  | ||||
| template<typename F> | ||||
| struct result_of_void_impl | ||||
| { | ||||
|   typedef void type; | ||||
| }; | ||||
|  | ||||
| template<typename R> | ||||
| struct result_of_void_impl<R (*)(void)> | ||||
| { | ||||
|   typedef R type; | ||||
| }; | ||||
|  | ||||
| template<typename R> | ||||
| struct result_of_void_impl<R (&)(void)> | ||||
| { | ||||
|   typedef R type; | ||||
| }; | ||||
| template<typename F, typename FArgs, bool HasResultType> struct get_result_of; | ||||
|  | ||||
| template<typename F, typename FArgs> | ||||
| struct result_of_impl<F, FArgs, true> | ||||
| struct get_result_of<F, FArgs, true> | ||||
| { | ||||
|   typedef typename F::result_type type; | ||||
| }; | ||||
|  | ||||
| template<typename FArgs> | ||||
| struct is_function_with_no_args : mpl::false_ {}; | ||||
| template<typename F, typename FArgs> | ||||
| struct get_result_of<F, FArgs, false> | ||||
| { | ||||
|   typedef typename F::template result<FArgs>::type type; | ||||
| }; | ||||
|  | ||||
| template<typename F> | ||||
| struct is_function_with_no_args<F(void)> : mpl::true_ {}; | ||||
| struct get_result_of<F, F(void), false> | ||||
| { | ||||
|   typedef void type; | ||||
| }; | ||||
|  | ||||
| template<typename F, typename FArgs> | ||||
| struct result_of_nested_result : F::template result<FArgs> | ||||
| {}; | ||||
|  | ||||
| template<typename F, typename FArgs> | ||||
| struct result_of_impl<F, FArgs, false> | ||||
|   : mpl::if_<is_function_with_no_args<FArgs>, | ||||
| 	     result_of_void_impl<F>, | ||||
| 	     result_of_nested_result<F, FArgs> >::type | ||||
| {}; | ||||
| struct result_of : get_result_of<F, FArgs, (has_result_type<F>::value)> {}; | ||||
|  | ||||
| } // end namespace detail | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| // 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 | ||||
| @@ -10,8 +9,8 @@ | ||||
| // You are welcome to contact the author at: | ||||
| //  fernando_cacciola@hotmail.com | ||||
| // | ||||
| #ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_04APR2007_HPP | ||||
| #ifndef BOOST_PP_IS_ITERATING | ||||
| #ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP | ||||
| #define BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP | ||||
|  | ||||
| #include <boost/utility/detail/in_place_factory_prefix.hpp> | ||||
|  | ||||
| @@ -19,59 +18,40 @@ namespace boost { | ||||
|  | ||||
| class typed_in_place_factory_base {} ; | ||||
|  | ||||
| #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() | ||||
| #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() ) | ||||
|  | ||||
| } // 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 | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| // (C) 2002, Fernando Luis Cacciola Carballal. | ||||
| // Copyright 2002, Fernando Luis Cacciola Carballal. | ||||
| // | ||||
| // Distributed under the Boost Software License, Version 1.0. (See | ||||
| // accompanying file LICENSE_1_0.txt or copy at | ||||
| @@ -9,9 +9,8 @@ | ||||
| #ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP | ||||
| #define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP | ||||
|  | ||||
| #include <boost/detail/select_type.hpp> | ||||
| #include <boost/type_traits/cv_traits.hpp> | ||||
| #include <boost/detail/workaround.hpp> | ||||
| #include "boost/detail/select_type.hpp" | ||||
| #include "boost/type_traits/cv_traits.hpp" | ||||
|  | ||||
| namespace boost { | ||||
|  | ||||
| @@ -40,11 +39,8 @@ struct non_const_T_base | ||||
| template<class T> | ||||
| struct select_base | ||||
| { | ||||
|   typedef | ||||
| #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) | ||||
|   typename | ||||
| #endif  | ||||
|     ::boost::detail::if_true< ::boost::is_const<T>::value > | ||||
|   typedef typename | ||||
|     boost::detail::if_true< ::boost::is_const<T>::value > | ||||
|       ::template then< const_T_base<T>, non_const_T_base<T> >::type type ; | ||||
| } ; | ||||
|  | ||||
|   | ||||
| @@ -33,4 +33,5 @@ test-suite utility | ||||
|         [ compile-fail ../value_init_test_fail1.cpp ] | ||||
|         [ compile-fail ../value_init_test_fail2.cpp ] | ||||
|         [ compile-fail ../value_init_test_fail3.cpp ] | ||||
|         [ run none_test.cpp ] | ||||
|     ; | ||||
|   | ||||
							
								
								
									
										22
									
								
								test/none_test.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								test/none_test.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| // Copyright 2007 Fernando Luis Cacciola Carballal.  Use, modification, and distribution | ||||
| // are subject to the Boost Software License, Version 1.0. (See | ||||
| // accompanying file LICENSE_1_0.txt or a copy at | ||||
| // http://www.boost.org/LICENSE_1_0.txt.) | ||||
|  | ||||
| // See http://www.boost.org/libs/utility for documentation. | ||||
|  | ||||
| // Boost test program for noost::none_t and boost::none | ||||
|  | ||||
| // Test strategy contributed by Richard Smith | ||||
|  | ||||
| #include <boost/optional/optional.hpp> // Test none.hpp is included with <optional.hpp> | ||||
|  | ||||
| // Left undefined to cause a linker error if this overload is incorrectly selected. | ||||
| void verify_no_implicit_conversion_to_int ( int i ) ; | ||||
|  | ||||
| void verify_no_implicit_conversion_to_int ( boost::optional<int> const& ) {} | ||||
|  | ||||
| int main()  | ||||
| { | ||||
|   verify_no_implicit_conversion_to_int( boost::none ); | ||||
| } | ||||
| @@ -24,24 +24,6 @@ struct int_result_type_and_float_result_of | ||||
|   template<typename F> struct result { typedef float type; }; | ||||
| }; | ||||
|  | ||||
| template<typename T> | ||||
| struct int_result_type_template { typedef int result_type; }; | ||||
|  | ||||
| template<typename T> | ||||
| struct int_result_of_template | ||||
| { | ||||
|   template<typename F> struct result; | ||||
|   template<typename This, typename That> struct result<This(That)> { typedef int type; }; | ||||
| }; | ||||
|  | ||||
| template<typename T> | ||||
| struct int_result_type_and_float_result_of_template | ||||
| { | ||||
|   typedef int result_type; | ||||
|   template<typename F> struct result; | ||||
|   template<typename This, typename That> struct result<This(That)> { typedef float type; }; | ||||
| }; | ||||
|  | ||||
| struct X {}; | ||||
|  | ||||
| int main() | ||||
| @@ -50,13 +32,10 @@ int main() | ||||
|  | ||||
|   typedef int (*func_ptr)(float, double); | ||||
|   typedef int (&func_ref)(float, double); | ||||
|   typedef int (*func_ptr_0)(); | ||||
|   typedef int (&func_ref_0)(); | ||||
|   typedef int (X::*mem_func_ptr)(float); | ||||
|   typedef int (X::*mem_func_ptr_c)(float) const; | ||||
|   typedef int (X::*mem_func_ptr_v)(float) volatile; | ||||
|   typedef int (X::*mem_func_ptr_cv)(float) const volatile; | ||||
|   typedef int (X::*mem_func_ptr_0)(); | ||||
|  | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value)); | ||||
| @@ -64,22 +43,11 @@ int main() | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of(char)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_template<void>(char)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value));  | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<func_ref_0()>::type, int>::value));  | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr(X,char)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_c(X,char)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_v(X,char)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_cv(X,char)>::type, int>::value)); | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value));  | ||||
|   BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value)); | ||||
|  | ||||
|   return 0; | ||||
| } | ||||
|   | ||||
| @@ -163,9 +163,9 @@ void f() { | ||||
|                 <code><em>N</em> > 0</code> or <code>void</code> | ||||
|                 when <code><em>N</em> = 0</code>. For additional | ||||
|                 information about <code>result_of</code>, see the | ||||
|                 C++ Library Technical Report, <a | ||||
|                 href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">N1836</a>, | ||||
|                 or, for motivation and design rationale, the <code>result_of</code> <a | ||||
|                 current draft of the C++ Library TR, <a | ||||
|                 href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2004/n1647.pdf">N1647</a>, | ||||
|                 or the <code>result_of</code> <a | ||||
|                 href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1454.html">proposal</a>.</p> | ||||
|  | ||||
|                 <p>Class template <code>result_of</code> resides in | ||||
|   | ||||
		Reference in New Issue
	
	Block a user