mirror of
https://github.com/boostorg/container.git
synced 2025-08-03 14:34:27 +02:00
Fix incomplete Trac #9689 ("Add piecewise_construct to boost::container") resolution. scoped_allocator_adaptor_test was missing pair construct overloads.
This commit is contained in:
@@ -25,12 +25,12 @@ namespace container {
|
|||||||
namespace container_detail {
|
namespace container_detail {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T* addressof(T& obj)
|
BOOST_CONTAINER_FORCEINLINE T* addressof(T& obj)
|
||||||
{
|
{
|
||||||
return static_cast<T*>(
|
return static_cast<T*>(
|
||||||
static_cast<void*>(
|
static_cast<void*>(
|
||||||
const_cast<char*>(
|
const_cast<char*>(
|
||||||
&reinterpret_cast<const char&>(obj)
|
&reinterpret_cast<const volatile char&>(obj)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -280,9 +280,131 @@ typename container_detail::enable_if_and
|
|||||||
, Pair* p, BOOST_RV_REF_BEG Pair2 BOOST_RV_REF_END x)
|
, Pair* p, BOOST_RV_REF_BEG Pair2 BOOST_RV_REF_END x)
|
||||||
{ (dispatch_uses_allocator)(construct_alloc, arg_alloc, p, ::boost::move(x.first), ::boost::move(x.second)); }
|
{ (dispatch_uses_allocator)(construct_alloc, arg_alloc, p, ::boost::move(x.first), ::boost::move(x.second)); }
|
||||||
|
|
||||||
//template <typename ConstructAlloc, typename ArgAlloc, class Pair, class Pair2>
|
|
||||||
//void dispatch_uses_allocator( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc
|
//piecewise construction from boost::tuple
|
||||||
// , pair<T1, T2>* p, piecewise_construct_t, tuple<Args1...> x, tuple<Args2...> y);
|
#define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BOOST_TUPLE_CODE(N,M)\
|
||||||
|
template< typename ConstructAlloc, typename ArgAlloc, class Pair \
|
||||||
|
, template<class, class, class, class, class, class, class, class, class, class> class BoostTuple \
|
||||||
|
BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \
|
||||||
|
typename container_detail::enable_if< container_detail::is_pair<Pair> >::type\
|
||||||
|
dispatch_uses_allocator( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t\
|
||||||
|
, BoostTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,N),::boost::tuples::null_type)> p\
|
||||||
|
, BoostTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::boost::tuples::null_type)> q)\
|
||||||
|
{\
|
||||||
|
(void)p; (void)q;\
|
||||||
|
(dispatch_uses_allocator)\
|
||||||
|
(construct_alloc, arg_alloc, container_detail::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_TMPL_GET##N);\
|
||||||
|
BOOST_TRY{\
|
||||||
|
(dispatch_uses_allocator)\
|
||||||
|
(construct_alloc, arg_alloc, container_detail::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_TMPL_GETQ##M);\
|
||||||
|
}\
|
||||||
|
BOOST_CATCH(...) {\
|
||||||
|
allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(pair->first));\
|
||||||
|
BOOST_RETHROW\
|
||||||
|
}\
|
||||||
|
BOOST_CATCH_END\
|
||||||
|
}\
|
||||||
|
//
|
||||||
|
BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BOOST_TUPLE_CODE)
|
||||||
|
#undef BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BOOST_TUPLE_CODE
|
||||||
|
|
||||||
|
//piecewise construction from Std Tuple
|
||||||
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
|
||||||
|
template< typename ConstructAlloc, typename ArgAlloc, class Pair
|
||||||
|
, template<class ...> class Tuple, class... Args1, class... Args2, size_t... Indexes1, size_t... Indexes2>
|
||||||
|
void dispatch_uses_allocator_index( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair
|
||||||
|
, Tuple<Args1...>& t1, Tuple<Args2...>& t2, index_tuple<Indexes1...>, index_tuple<Indexes2...>)
|
||||||
|
{
|
||||||
|
(void)t1; (void)t2;
|
||||||
|
(dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(pair->first), ::boost::forward<Args1>(get<Indexes1>(t1))...);
|
||||||
|
BOOST_TRY{
|
||||||
|
(dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(pair->second), ::boost::forward<Args2>(get<Indexes2>(t2))...);
|
||||||
|
}
|
||||||
|
BOOST_CATCH(...){
|
||||||
|
allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(pair->first));
|
||||||
|
BOOST_RETHROW
|
||||||
|
}
|
||||||
|
BOOST_CATCH_END
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename ConstructAlloc, typename ArgAlloc, class Pair
|
||||||
|
, template<class ...> class Tuple, class... Args1, class... Args2>
|
||||||
|
typename container_detail::enable_if< container_detail::is_pair<Pair> >::type
|
||||||
|
dispatch_uses_allocator( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t
|
||||||
|
, Tuple<Args1...> t1, Tuple<Args2...> t2)
|
||||||
|
{
|
||||||
|
(dispatch_uses_allocator_index)( construct_alloc, arg_alloc, pair, t1, t2
|
||||||
|
, typename build_number_seq<sizeof...(Args1)>::type()
|
||||||
|
, typename build_number_seq<sizeof...(Args2)>::type());
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(BOOST_MSVC) && (_CPPLIB_VER == 520)
|
||||||
|
|
||||||
|
//MSVC 2010 tuple implementation
|
||||||
|
#define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE(N,M)\
|
||||||
|
template< typename ConstructAlloc, typename ArgAlloc, class Pair\
|
||||||
|
, template<class, class, class, class, class, class, class, class, class, class> class StdTuple\
|
||||||
|
BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \
|
||||||
|
typename container_detail::enable_if< container_detail::is_pair<Pair> >::type\
|
||||||
|
dispatch_uses_allocator(ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t\
|
||||||
|
, StdTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,N),::std::tr1::_Nil)> p\
|
||||||
|
, StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::std::tr1::_Nil)> q)\
|
||||||
|
{\
|
||||||
|
(void)p; (void)q;\
|
||||||
|
(dispatch_uses_allocator)\
|
||||||
|
(construct_alloc, arg_alloc, container_detail::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_GET_IDX##N);\
|
||||||
|
BOOST_TRY{\
|
||||||
|
(dispatch_uses_allocator)\
|
||||||
|
(construct_alloc, arg_alloc, container_detail::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_GET_IDXQ##M);\
|
||||||
|
}\
|
||||||
|
BOOST_CATCH(...) {\
|
||||||
|
allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(pair->first));\
|
||||||
|
BOOST_RETHROW\
|
||||||
|
}\
|
||||||
|
BOOST_CATCH_END\
|
||||||
|
}\
|
||||||
|
//
|
||||||
|
BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE)
|
||||||
|
#undef BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE
|
||||||
|
|
||||||
|
#elif defined(BOOST_MSVC) && (_CPPLIB_VER == 540)
|
||||||
|
#if _VARIADIC_MAX >= 9
|
||||||
|
#define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT 9
|
||||||
|
#else
|
||||||
|
#define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT BOOST_MOVE_ADD(_VARIADIC_MAX, 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//MSVC 2012 tuple implementation
|
||||||
|
#define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_CODE(N,M)\
|
||||||
|
template< typename ConstructAlloc, typename ArgAlloc, class Pair\
|
||||||
|
, template<BOOST_MOVE_REPEAT(_VARIADIC_MAX, class), class, class, class> class StdTuple \
|
||||||
|
BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \
|
||||||
|
typename container_detail::enable_if< container_detail::is_pair<Pair> >::type\
|
||||||
|
dispatch_uses_allocator\
|
||||||
|
( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t\
|
||||||
|
, StdTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),N),::std::_Nil) > p\
|
||||||
|
, StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),M),::std::_Nil) > q)\
|
||||||
|
{\
|
||||||
|
(void)p; (void)q;\
|
||||||
|
(dispatch_uses_allocator)\
|
||||||
|
(construct_alloc, arg_alloc, container_detail::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_GET_IDX##N);\
|
||||||
|
BOOST_TRY{\
|
||||||
|
(dispatch_uses_allocator)\
|
||||||
|
(construct_alloc, arg_alloc, container_detail::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_GET_IDXQ##M);\
|
||||||
|
}\
|
||||||
|
BOOST_CATCH(...) {\
|
||||||
|
allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(pair->first));\
|
||||||
|
BOOST_RETHROW\
|
||||||
|
}\
|
||||||
|
BOOST_CATCH_END\
|
||||||
|
}\
|
||||||
|
//
|
||||||
|
BOOST_MOVE_ITER2D_0TOMAX(BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_CODE)
|
||||||
|
#undef BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE
|
||||||
|
#undef BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT
|
||||||
|
|
||||||
|
#endif //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
|
||||||
} //namespace container_detail
|
} //namespace container_detail
|
||||||
|
|
||||||
|
@@ -49,6 +49,10 @@
|
|||||||
#define BOOST_CONTAINER_FALLTHOUGH BOOST_FALLTHOUGH;
|
#define BOOST_CONTAINER_FALLTHOUGH BOOST_FALLTHOUGH;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) || (defined(BOOST_MSVC) && (BOOST_MSVC == 1700 || BOOST_MSVC == 1600))
|
||||||
|
#define BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
|
||||||
|
#endif
|
||||||
|
|
||||||
//Macros for documentation purposes. For code, expands to the argument
|
//Macros for documentation purposes. For code, expands to the argument
|
||||||
#define BOOST_CONTAINER_IMPDEF(TYPE) TYPE
|
#define BOOST_CONTAINER_IMPDEF(TYPE) TYPE
|
||||||
#define BOOST_CONTAINER_SEEDOC(TYPE) TYPE
|
#define BOOST_CONTAINER_SEEDOC(TYPE) TYPE
|
||||||
|
@@ -15,10 +15,16 @@
|
|||||||
// move
|
// move
|
||||||
#include <boost/move/utility_core.hpp>
|
#include <boost/move/utility_core.hpp>
|
||||||
#include <boost/move/adl_move_swap.hpp>
|
#include <boost/move/adl_move_swap.hpp>
|
||||||
|
//boost
|
||||||
|
#include <boost/tuple/tuple.hpp>
|
||||||
// std
|
// std
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
|
||||||
|
#include <tuple>
|
||||||
|
#endif
|
||||||
|
|
||||||
//test
|
//test
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
@@ -894,7 +900,81 @@ int main()
|
|||||||
BOOST_TEST(dummy.second.value == 0);
|
BOOST_TEST(dummy.second.value == 0);
|
||||||
dummy.~MarkTypePair();
|
dummy.~MarkTypePair();
|
||||||
}
|
}
|
||||||
|
#if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
|
||||||
|
//Check construction with 0 user arguments and Std tuple
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
|
||||||
|
BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 0);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 0);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 0);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
|
||||||
|
BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 0);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 0);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<>());
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 0);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
#endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
|
||||||
//Check construction with 1 user arguments for each pair
|
//Check construction with 1 user arguments for each pair
|
||||||
{
|
{
|
||||||
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
||||||
@@ -932,6 +1012,82 @@ int main()
|
|||||||
BOOST_TEST(dummy.second.value == 2);
|
BOOST_TEST(dummy.second.value == 2);
|
||||||
dummy.~MarkTypePair();
|
dummy.~MarkTypePair();
|
||||||
}
|
}
|
||||||
|
//Check construction with 1 user arguments for each pair and Boost tuple
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(1), boost::tuple<int>(1));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.first.value == 1);
|
||||||
|
BOOST_TEST(dummy.second.value == 1);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(1), boost::tuple<int>(1));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.first.value == 1);
|
||||||
|
BOOST_TEST(dummy.second.value == 1);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(2), boost::tuple<int>(2));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.first.value == 2);
|
||||||
|
BOOST_TEST(dummy.second.value == 2);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
#if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
|
||||||
|
//Check construction with 1 user arguments for each pair and Boost tuple
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<int>(1), std::tuple<int>(1));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.first.value == 1);
|
||||||
|
BOOST_TEST(dummy.second.value == 1);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<int>(1), std::tuple<int>(1));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.first.value == 1);
|
||||||
|
BOOST_TEST(dummy.second.value == 1);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<int>(2), std::tuple<int>(2));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.first.value == 2);
|
||||||
|
BOOST_TEST(dummy.second.value == 2);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
#endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
|
||||||
//Check construction with pair copy construction
|
//Check construction with pair copy construction
|
||||||
{
|
{
|
||||||
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
||||||
@@ -1099,6 +1255,82 @@ int main()
|
|||||||
BOOST_TEST(dummy.second.value == 2);
|
BOOST_TEST(dummy.second.value == 2);
|
||||||
dummy.~MarkTypePair();
|
dummy.~MarkTypePair();
|
||||||
}
|
}
|
||||||
|
//Check construction with 0/1 arguments for each pair and Boost tuple
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, boost::tuple<>(), boost::tuple<int>(1));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 1);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, boost::tuple<int>(1), boost::tuple<>());
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.first.value == 1);
|
||||||
|
BOOST_TEST(dummy.second.value == 0);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, boost::tuple<>(), boost::tuple<int>(2));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 2);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
#if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
|
||||||
|
//Check construction with 0/1 arguments for each pair and Boost tuple
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<int>(1));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 1);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<int>(1), std::tuple<>());
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
|
||||||
|
BOOST_TEST(dummy.first.value == 1);
|
||||||
|
BOOST_TEST(dummy.second.value == 0);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
|
||||||
|
typedef pair<MarkType, MarkType> MarkTypePair;
|
||||||
|
MarkTypePair dummy;
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
s0i.construct(&dummy, piecewise_construct, std::tuple<>(), std::tuple<int>(2));
|
||||||
|
BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
|
||||||
|
BOOST_TEST(dummy.first.value == 0);
|
||||||
|
BOOST_TEST(dummy.second.value == 2);
|
||||||
|
dummy.~MarkTypePair();
|
||||||
|
}
|
||||||
|
#endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user