Include <new> to get std::bad_alloc.

[SVN r42881]
This commit is contained in:
Daniel James
2008-01-20 17:37:21 +00:00
parent 01df4d9dc2
commit 68f5afc9be
2 changed files with 8 additions and 2 deletions

View File

@ -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
};

View File

@ -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"