Fix std::function allocator constructors in C++03.

The C++03 version of function tried to default construct the allocator
in the uses allocator constructors when no allocation was performed. These
constructors would fail to compile when used with allocators that had no
default constructor.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@239708 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2015-06-14 23:30:09 +00:00
parent 4983580dc5
commit b05f0599c0
5 changed files with 239 additions and 144 deletions

View File

@@ -74,10 +74,10 @@ public:
}
++time_to_throw;
++alloc_count;
return (pointer)std::malloc(n * sizeof(T));
return (pointer)::operator new(n * sizeof(T));
}
void deallocate(pointer p, size_type n)
{assert(data_ >= 0); --alloc_count; std::free(p);}
{assert(data_ >= 0); --alloc_count; ::operator delete((void*)p);}
size_type max_size() const throw()
{return UINT_MAX / sizeof(T);}
void construct(pointer p, const T& val)
@@ -134,10 +134,10 @@ public:
}
++time_to_throw;
++alloc_count;
return (pointer)std::malloc(n * sizeof(T));
return (pointer)::operator new (n * sizeof(T));
}
void deallocate(pointer p, size_type n)
{assert(data_ >= 0); --alloc_count; std::free(p);}
{assert(data_ >= 0); --alloc_count; ::operator delete((void*)p); }
size_type max_size() const throw()
{return UINT_MAX / sizeof(T);}
void construct(pointer p, const T& val)
@@ -200,9 +200,9 @@ public:
template <class U> other_allocator(const other_allocator<U>& a)
: data_(a.data_) {}
T* allocate(std::size_t n)
{return (T*)std::malloc(n * sizeof(T));}
{return (T*)::operator new(n * sizeof(T));}
void deallocate(T* p, std::size_t n)
{std::free(p);}
{::operator delete((void*)p);}
other_allocator select_on_container_copy_construction() const
{return other_allocator(-2);}