From d469aff04363b8fa1dbada855702f629ed8e5868 Mon Sep 17 00:00:00 2001 From: Fernando Cacciola Date: Fri, 28 Nov 2003 14:36:21 +0000 Subject: [PATCH] Moved from "utility" to "detail" until a Fast Track Review formalizes it. [SVN r20983] --- include/boost/detail/in_place_factory.hpp | 56 ++++++++++++++++++ include/boost/detail/none.hpp | 31 ++++++++++ .../boost/detail/typed_in_place_factory.hpp | 57 +++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 include/boost/detail/in_place_factory.hpp create mode 100644 include/boost/detail/none.hpp create mode 100644 include/boost/detail/typed_in_place_factory.hpp diff --git a/include/boost/detail/in_place_factory.hpp b/include/boost/detail/in_place_factory.hpp new file mode 100644 index 0000000..f22b4e4 --- /dev/null +++ b/include/boost/detail/in_place_factory.hpp @@ -0,0 +1,56 @@ +// 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 + +#include + +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 \ + 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 + diff --git a/include/boost/detail/none.hpp b/include/boost/detail/none.hpp new file mode 100644 index 0000000..d7db5d1 --- /dev/null +++ b/include/boost/detail/none.hpp @@ -0,0 +1,31 @@ +// 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_NONE_17SEP2003_HPP +#define BOOST_UTILITY_NONE_17SEP2003_HPP + +#include "boost/detail/none_t.hpp" + +// NOTE: Borland users have to include this header outside any precompiled headers +// (bcc<=5.64 cannot include instance data in a precompiled header) + +namespace boost { + +namespace { + +detail::none_t const none = ((detail::none_t)0) ; + +} + +} // namespace boost + +#endif + diff --git a/include/boost/detail/typed_in_place_factory.hpp b/include/boost/detail/typed_in_place_factory.hpp new file mode 100644 index 0000000..2b01af9 --- /dev/null +++ b/include/boost/detail/typed_in_place_factory.hpp @@ -0,0 +1,57 @@ +// 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 + +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 + +#endif +