mirror of
https://github.com/boostorg/core.git
synced 2025-11-29 05:40:14 +01:00
Revise allocator_access implementation
This commit is contained in:
@@ -8,33 +8,34 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
struct A1 {
|
||||
A1(int v)
|
||||
: value(v) { }
|
||||
|
||||
typedef T value_type;
|
||||
A1(int n)
|
||||
: value(n) { }
|
||||
int value;
|
||||
};
|
||||
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
struct A2 {
|
||||
A2(int v)
|
||||
: value(v) { }
|
||||
|
||||
typedef T value_type;
|
||||
A2(int n)
|
||||
: value(n) { }
|
||||
A2 select_on_container_copy_construction() const {
|
||||
return A2(value + 1);
|
||||
}
|
||||
|
||||
int value;
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ(1,
|
||||
boost::allocator_select_on_container_copy_construction(A1(1)).value);
|
||||
#if defined(BOOST_CORE_ALLOCATOR_DETECTION)
|
||||
BOOST_TEST_EQ(2,
|
||||
boost::allocator_select_on_container_copy_construction(A2(1)).value);
|
||||
BOOST_TEST_EQ(1, boost::
|
||||
allocator_select_on_container_copy_construction(A1<int>(1)).value);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
BOOST_TEST_EQ(2, boost::
|
||||
allocator_select_on_container_copy_construction(A2<int>(1)).value);
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user