mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 14:04:26 +02:00
Fixed error in default_init_allocator, it should not construct objects, only allocate raw memory.
[SVN r85999]
This commit is contained in:
@@ -11,14 +11,6 @@
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
|
||||
// TODO: Disable parts of the unit test that should not run when BOOST_NO_EXCEPTIONS
|
||||
// if exceptions are enabled there must be a user defined throw_exception function
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
namespace boost {
|
||||
void throw_exception(std::exception const &){}; // user defined
|
||||
} // namespace boost
|
||||
#endif // BOOST_NO_EXCEPTIONS
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
|
@@ -78,9 +78,9 @@ class default_init_allocator
|
||||
T* allocate(std::size_t n)
|
||||
{
|
||||
//Initialize memory to a pattern
|
||||
T *const p = ::new T[n];
|
||||
unsigned char *puc_raw = reinterpret_cast<unsigned char*>(p);
|
||||
std::size_t max = sizeof(T)*n;
|
||||
const std::size_t max = sizeof(T)*n;
|
||||
unsigned char *puc_raw = ::new unsigned char[max];
|
||||
|
||||
if(base_t::s_ascending){
|
||||
for(std::size_t i = 0; i != max; ++i){
|
||||
puc_raw[i] = static_cast<unsigned char>(s_pattern++);
|
||||
@@ -91,11 +91,11 @@ class default_init_allocator
|
||||
puc_raw[i] = static_cast<unsigned char>(s_pattern--);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
return (T*)puc_raw;;
|
||||
}
|
||||
|
||||
void deallocate(T *p, std::size_t)
|
||||
{ delete[] p; }
|
||||
{ delete[] (unsigned char*)p; }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
Reference in New Issue
Block a user