mirror of
https://github.com/boostorg/unordered.git
synced 2025-10-07 21:21:03 +02:00
Update test allocators to be C++11 compliant by making them templates on the pointer type
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
// Copyright 2006-2009 Daniel James.
|
||||
// Copyright 2022 Christian Mazakas
|
||||
// Distributed under 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)
|
||||
|
||||
@@ -475,32 +476,34 @@ namespace test {
|
||||
}
|
||||
}
|
||||
|
||||
void construct(pointer p, T const& t)
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class U, class Arg>
|
||||
void construct(U* p, Arg const& t)
|
||||
{
|
||||
UNORDERED_SCOPE(allocator::construct(T*, T))
|
||||
UNORDERED_SCOPE(allocator::construct(U*, Arg))
|
||||
{
|
||||
UNORDERED_EPOINT("Mock allocator construct function.");
|
||||
new (p) T(t);
|
||||
new (p) U(t);
|
||||
}
|
||||
test::detail::tracker.track_construct((void*)p, sizeof(T), tag_);
|
||||
test::detail::tracker.track_construct((void*)p, sizeof(U), tag_);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args)
|
||||
#else
|
||||
template <class U, class... Args> void construct(U* p, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
UNORDERED_SCOPE(allocator::construct(pointer, BOOST_FWD_REF(Args)...))
|
||||
UNORDERED_SCOPE(allocator::construct(U*, BOOST_FWD_REF(Args)...))
|
||||
{
|
||||
UNORDERED_EPOINT("Mock allocator construct function.");
|
||||
new (p) T(boost::forward<Args>(args)...);
|
||||
new (p) U(boost::forward<Args>(args)...);
|
||||
}
|
||||
test::detail::tracker.track_construct((void*)p, sizeof(T), tag_);
|
||||
test::detail::tracker.track_construct((void*)p, sizeof(U), tag_);
|
||||
}
|
||||
#endif
|
||||
|
||||
void destroy(T* p)
|
||||
template <class U>
|
||||
void destroy(U* p)
|
||||
{
|
||||
test::detail::tracker.track_destroy((void*)p, sizeof(T), tag_);
|
||||
p->~T();
|
||||
test::detail::tracker.track_destroy((void*)p, sizeof(U), tag_);
|
||||
p->~U();
|
||||
}
|
||||
|
||||
size_type max_size() const
|
||||
@@ -654,32 +657,35 @@ namespace test {
|
||||
}
|
||||
}
|
||||
|
||||
void construct(pointer p, T const& t)
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class U, class V>
|
||||
void construct(U* p, V const& v)
|
||||
{
|
||||
UNORDERED_SCOPE(allocator2::construct(T*, T))
|
||||
UNORDERED_SCOPE(allocator2::construct(U*, V))
|
||||
{
|
||||
UNORDERED_EPOINT("Mock allocator2 construct function.");
|
||||
new (p) T(t);
|
||||
new (p) U(v);
|
||||
}
|
||||
test::detail::tracker.track_construct((void*)p, sizeof(T), tag_);
|
||||
test::detail::tracker.track_construct((void*)p, sizeof(U), tag_);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template <class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args)
|
||||
#else
|
||||
template <class U, class... Args>
|
||||
void construct(U* p, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
UNORDERED_SCOPE(allocator2::construct(pointer, BOOST_FWD_REF(Args)...))
|
||||
UNORDERED_SCOPE(allocator2::construct(U*, BOOST_FWD_REF(Args)...))
|
||||
{
|
||||
UNORDERED_EPOINT("Mock allocator2 construct function.");
|
||||
new (p) T(boost::forward<Args>(args)...);
|
||||
new (p) U(boost::forward<Args>(args)...);
|
||||
}
|
||||
test::detail::tracker.track_construct((void*)p, sizeof(T), tag_);
|
||||
test::detail::tracker.track_construct((void*)p, sizeof(U), tag_);
|
||||
}
|
||||
#endif
|
||||
|
||||
void destroy(T* p)
|
||||
template <class U>
|
||||
void destroy(U* p)
|
||||
{
|
||||
test::detail::tracker.track_destroy((void*)p, sizeof(T), tag_);
|
||||
p->~T();
|
||||
test::detail::tracker.track_destroy((void*)p, sizeof(U), tag_);
|
||||
p->~U();
|
||||
}
|
||||
|
||||
size_type max_size() const
|
||||
|
Reference in New Issue
Block a user