mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 15:04:00 +00:00
In-place factories moved from /detail to /utility
New value_initalized tests added [SVN r25313]
This commit is contained in:
parent
0fcc554abd
commit
325bd73df7
33
include/boost/utility/detail/in_place_factory_prefix.hpp
Normal file
33
include/boost/utility/detail/in_place_factory_prefix.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
||||||
|
#define BOOST_UTILITY_DETAIL_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_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
23
include/boost/utility/detail/in_place_factory_suffix.hpp
Normal file
23
include/boost/utility/detail/in_place_factory_suffix.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// 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_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_25AGO2003_HPP
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
56
include/boost/utility/in_place_factory.hpp
Normal file
56
include/boost/utility/in_place_factory.hpp
Normal file
@ -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 <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() )
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
57
include/boost/utility/typed_in_place_factory.hpp
Normal file
57
include/boost/utility/typed_in_place_factory.hpp
Normal file
@ -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 <boost/detail/in_place_factory_prefix.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
|
||||||
|
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() )
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#include <boost/detail/in_place_factory_suffix.hpp>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -18,7 +18,7 @@ local test_monitor = <lib>@boost/libs/test/build/boost_test_exec_monitor ;
|
|||||||
|
|
||||||
# Please keep the tests ordered by filename
|
# Please keep the tests ordered by filename
|
||||||
test-suite utility
|
test-suite utility
|
||||||
:
|
:
|
||||||
[ run ../addressof_test.cpp $(test_monitor) ]
|
[ run ../addressof_test.cpp $(test_monitor) ]
|
||||||
[ run ../assert_test.cpp ]
|
[ run ../assert_test.cpp ]
|
||||||
[ run ../base_from_member_test.cpp ]
|
[ run ../base_from_member_test.cpp ]
|
||||||
@ -37,13 +37,16 @@ test-suite utility
|
|||||||
[ run ../enable_if_partial_specializations.cpp $(test_monitor) ]
|
[ run ../enable_if_partial_specializations.cpp $(test_monitor) ]
|
||||||
[ run ../iterator_traits_test.cpp ]
|
[ run ../iterator_traits_test.cpp ]
|
||||||
[ run ../iterators_test.cpp $(test_monitor) ]
|
[ run ../iterators_test.cpp $(test_monitor) ]
|
||||||
[ run next_prior_test.cpp $(test_monitor) ]
|
[ run next_prior_test.cpp $(test_monitor) ]
|
||||||
[ compile-fail ../noncopyable_test.cpp ]
|
[ compile-fail ../noncopyable_test.cpp ]
|
||||||
[ run ../numeric_traits_test.cpp ]
|
[ run ../numeric_traits_test.cpp ]
|
||||||
[ run ../operators_test.cpp $(test_monitor) ]
|
[ run ../operators_test.cpp $(test_monitor) ]
|
||||||
[ compile ../ref_ct_test.cpp ]
|
[ compile ../ref_ct_test.cpp ]
|
||||||
[ run ../ref_test.cpp $(test_monitor) ]
|
[ run ../ref_test.cpp $(test_monitor) ]
|
||||||
[ compile result_of_test.cpp ]
|
[ compile result_of_test.cpp ]
|
||||||
[ run ../shared_iterator_test.cpp ]
|
[ run ../shared_iterator_test.cpp ]
|
||||||
[ run ../value_init_test.cpp ]
|
[ run ../value_init_test.cpp ]
|
||||||
|
[ compile-fail ../value_init_test_fail1.cpp ]
|
||||||
|
[ compile-fail ../value_init_test_fail2.cpp ]
|
||||||
|
[ compile-fail ../value_init_test_fail3.cpp ]
|
||||||
;
|
;
|
||||||
|
@ -11,7 +11,7 @@ import testing ;
|
|||||||
|
|
||||||
# Please keep the tests ordered by filename
|
# Please keep the tests ordered by filename
|
||||||
test-suite utility
|
test-suite utility
|
||||||
:
|
:
|
||||||
[ run ../addressof_test.cpp ../../test/build//boost_test_exec_monitor ]
|
[ run ../addressof_test.cpp ../../test/build//boost_test_exec_monitor ]
|
||||||
[ run ../assert_test.cpp ]
|
[ run ../assert_test.cpp ]
|
||||||
[ run ../base_from_member_test.cpp ]
|
[ run ../base_from_member_test.cpp ]
|
||||||
@ -39,4 +39,7 @@ test-suite utility
|
|||||||
[ compile result_of_test.cpp ]
|
[ compile result_of_test.cpp ]
|
||||||
[ run ../shared_iterator_test.cpp ]
|
[ run ../shared_iterator_test.cpp ]
|
||||||
[ run ../value_init_test.cpp ]
|
[ run ../value_init_test.cpp ]
|
||||||
|
[ compile-fail ../value_init_test_fail1.cpp ]
|
||||||
|
[ compile-fail ../value_init_test_fail2.cpp ]
|
||||||
|
[ compile-fail ../value_init_test_fail3.cpp ]
|
||||||
;
|
;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user