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