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,24 +8,24 @@ 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 A {
|
||||
typedef int* pointer;
|
||||
typedef int size_type;
|
||||
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef std::size_t size_type;
|
||||
A()
|
||||
: value() { }
|
||||
|
||||
pointer allocate(size_type n) {
|
||||
T* allocate(std::size_t n) {
|
||||
value = n;
|
||||
return &value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_type value;
|
||||
std::size_t value;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
BOOST_TEST_EQ(*boost::allocator_allocate(a, 5), 5);
|
||||
A<int> a;
|
||||
BOOST_TEST_NOT(boost::allocator_allocate(a, 5));
|
||||
BOOST_TEST_EQ(a.value, 5);
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user