In-place factories moved from /detail to /utility

New value_initalized tests added


[SVN r25313]
This commit is contained in:
Fernando Cacciola
2004-09-21 14:54:32 +00:00
parent 7717a785de
commit 07a80c1b9b
8 changed files with 20 additions and 189 deletions

View File

@ -1,56 +0,0 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/lib/optional for documentation.
//
// You are welcome to contact the author at:
// fernando_cacciola@hotmail.com
//
#ifndef BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
#define BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
#include <boost/detail/in_place_factory_prefix.hpp>
#include <boost/type.hpp>
namespace boost {
class InPlaceFactoryBase {} ;
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS(z,n,_) \
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
class BOOST_PP_CAT(InPlaceFactory, BOOST_PP_INC(n) ) : public InPlaceFactoryBase \
{ \
public: \
\
BOOST_PP_CAT(InPlaceFactory, 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(InPlaceFactory, 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(InPlaceFactory, 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
#endif

View File

@ -1,33 +0,0 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/lib/optional for documentation.
//
// You are welcome to contact the author at:
// fernando_cacciola@hotmail.com
//
#ifndef BOOST_UTILITY_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
#define BOOST_UTILITY_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
#include <boost/config.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>
#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_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
#endif

View File

@ -1,23 +0,0 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/lib/optional for documentation.
//
// You are welcome to contact the author at:
// fernando_cacciola@hotmail.com
//
#ifndef BOOST_UTILITY_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
#define BOOST_UTILITY_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_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
#endif

View File

@ -1,57 +0,0 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/lib/optional for documentation.
//
// You are welcome to contact the author at:
// fernando_cacciola@hotmail.com
//
#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
#define BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
#include <boost/detail/in_place_factory_prefix.hpp>
namespace boost {
class TypedInPlaceFactoryBase {} ;
#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(TypedInPlaceFactory, BOOST_PP_INC(n) ) : public TypedInPlaceFactoryBase \
{ \
public: \
\
typedef T value_type ; \
\
BOOST_PP_CAT(TypedInPlaceFactory, 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(TypedInPlaceFactory, 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(TypedInPlaceFactory, 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/detail/in_place_factory_suffix.hpp>
#endif

View File

@ -77,8 +77,8 @@
namespace boost { namespace boost {
class InPlaceFactoryBase ; class in_place_factory_base ;
class TypedInPlaceFactoryBase ; class typed_in_place_factory_base ;
namespace optional_detail { namespace optional_detail {
@ -266,7 +266,7 @@ class optional_base : public optional_tag
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
// Constructs in-place using the given factory // Constructs in-place using the given factory
template<class Expr> template<class Expr>
void construct ( Expr const& factory, InPlaceFactoryBase const* ) void construct ( Expr const& factory, in_place_factory_base const* )
{ {
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ; BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
factory.BOOST_NESTED_TEMPLATE apply<value_type>(m_storage.address()) ; factory.BOOST_NESTED_TEMPLATE apply<value_type>(m_storage.address()) ;
@ -275,7 +275,7 @@ class optional_base : public optional_tag
// Constructs in-place using the given typed factory // Constructs in-place using the given typed factory
template<class Expr> template<class Expr>
void construct ( Expr const& factory, TypedInPlaceFactoryBase const* ) void construct ( Expr const& factory, typed_in_place_factory_base const* )
{ {
BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ; BOOST_STATIC_ASSERT ( ::boost::mpl::not_<is_reference_predicate>::value ) ;
factory.apply(m_storage.address()) ; factory.apply(m_storage.address()) ;

View File

@ -15,11 +15,11 @@
#define BOOST_ENABLE_ASSERT_HANDLER #define BOOST_ENABLE_ASSERT_HANDLER
#include "boost/optional.hpp" #include "boost/optional/optional.hpp"
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#include "boost/detail/in_place_factory.hpp" #include "boost/utility/in_place_factory.hpp"
#include "boost/detail/typed_in_place_factory.hpp" #include "boost/utility/typed_in_place_factory.hpp"
#endif #endif
#ifdef __BORLANDC__ #ifdef __BORLANDC__

View File

@ -15,10 +15,10 @@
#define BOOST_ENABLE_ASSERT_HANDLER #define BOOST_ENABLE_ASSERT_HANDLER
#include "boost/optional.hpp" #include "boost/optional/optional.hpp"
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#include "boost/detail/in_place_factory.hpp" #include "boost/utility/in_place_factory.hpp"
#endif #endif
#ifdef __BORLANDC__ #ifdef __BORLANDC__

View File

@ -15,10 +15,10 @@
#define BOOST_ENABLE_ASSERT_HANDLER #define BOOST_ENABLE_ASSERT_HANDLER
#include "boost/optional.hpp" #include "boost/optional/optional.hpp"
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
#include "boost/detail/typed_in_place_factory.hpp" #include "boost/utility/typed_in_place_factory.hpp"
#endif #endif
#ifdef __BORLANDC__ #ifdef __BORLANDC__