mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 19:37:14 +02:00
Include <new> to get std::bad_alloc.
[SVN r42881]
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <boost/limits.hpp>
|
||||
#include <new>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
@ -39,7 +40,9 @@ namespace test
|
||||
|
||||
pointer allocate(size_type n) {
|
||||
using namespace std;
|
||||
return static_cast<T*>(malloc(n * sizeof(T)));
|
||||
T* ptr = static_cast<T*>(malloc(n * sizeof(T)));
|
||||
if(!ptr) throw std::bad_alloc();
|
||||
return ptr;
|
||||
}
|
||||
|
||||
pointer allocate(size_type n, const_pointer u) { return allocate(n); }
|
||||
@ -71,7 +74,9 @@ namespace test
|
||||
}
|
||||
char* _Charalloc(size_type n) {
|
||||
using namespace std;
|
||||
return static_cast<char*>(malloc(n * sizeof(char)));
|
||||
T* ptr = static_cast<T*>(malloc(n * sizeof(char)));
|
||||
if(!ptr) throw std::bad_alloc();
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <boost/limits.hpp>
|
||||
#include <new>
|
||||
#include "../helpers/fwd.hpp"
|
||||
#include "../helpers/allocator.hpp"
|
||||
#include "./memory.hpp"
|
||||
|
Reference in New Issue
Block a user