#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
constexpr auto OverAligned = alignof(std::max_align_t) * 2;
int unsized_delete_called = 0;
aligned_delete_called = 0;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete [] (void* p, std::align_val_t a) throw()
+void operator delete [] (void* p, std::align_val_t a) TEST_NOEXCEPT
{
++aligned_delete_called;
std::free(p);
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
constexpr auto OverAligned = alignof(std::max_align_t) * 2;
int A_constructed = 0;
int new_called = 0;
alignas(OverAligned) char Buff[OverAligned * 3];
-void* operator new[](std::size_t s, std::align_val_t a) throw(std::bad_alloc)
+void* operator new[](std::size_t s, std::align_val_t a) TEST_THROW_SPEC(std::bad_alloc)
{
assert(!new_called);
assert(s <= sizeof(Buff));
return Buff;
}
-void operator delete[](void* p, std::align_val_t a) throw()
+void operator delete[](void* p, std::align_val_t a) TEST_NOEXCEPT
{
assert(p == Buff);
assert(static_cast<std::size_t>(a) == OverAligned);
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
constexpr auto OverAligned = alignof(std::max_align_t) * 2;
int A_constructed = 0;
alignas(OverAligned) char DummyData[OverAligned * 4];
-void* operator new[](std::size_t s, std::align_val_t a) throw(std::bad_alloc)
+void* operator new[](std::size_t s, std::align_val_t a) TEST_THROW_SPEC(std::bad_alloc)
{
assert(new_called == 0); // We already allocated
assert(s <= sizeof(DummyData));
return DummyData;
}
-void operator delete[](void* p, std::align_val_t a) throw()
+void operator delete[](void* p, std::align_val_t a) TEST_NOEXCEPT
{
assert(new_called == 1);
--new_called;
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
++new_called;
void* ret = std::malloc(s);
return ret;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
--new_called;
std::free(p);
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
volatile int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
++new_called;
void* ret = std::malloc(s);
return ret;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
--new_called;
std::free(p);
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete[](void* p) throw()
+void operator delete[](void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete[](void* p, const std::nothrow_t&) throw()
+void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete[](void* p, std::size_t) throw()
+void operator delete[](void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete[](void* p) throw()
+void operator delete[](void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete[](void* p, const std::nothrow_t&) throw()
+void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete[](void* p, std::size_t) throw()
+void operator delete[](void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int delete_called = 0;
int delete_nothrow_called = 0;
-void operator delete[](void* p) throw()
+void operator delete[](void* p) TEST_NOEXCEPT
{
++delete_called;
std::free(p);
}
-void operator delete[](void* p, const std::nothrow_t&) throw()
+void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++delete_nothrow_called;
std::free(p);
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete[](void* p) throw()
+void operator delete[](void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete[](void* p, const std::nothrow_t&) throw()
+void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete[](void* p, std::size_t) throw()
+void operator delete[](void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
constexpr auto OverAligned = alignof(std::max_align_t) * 2;
int unsized_delete_called = 0;
aligned_delete_called = 0;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete(void* p, std::align_val_t a) throw()
+void operator delete(void* p, std::align_val_t a) TEST_NOEXCEPT
{
++aligned_delete_called;
std::free(p);
#include <cassert>
#include <limits>
+#include "test_macros.h"
constexpr auto OverAligned = alignof(std::max_align_t) * 2;
int new_called = 0;
alignas(OverAligned) char Buff[OverAligned * 2];
-void* operator new(std::size_t s, std::align_val_t a) throw(std::bad_alloc)
+void* operator new(std::size_t s, std::align_val_t a) TEST_THROW_SPEC(std::bad_alloc)
{
assert(!new_called);
assert(s <= sizeof(Buff));
return Buff;
}
-void operator delete(void* p, std::align_val_t a) throw()
+void operator delete(void* p, std::align_val_t a) TEST_NOEXCEPT
{
assert(p == Buff);
assert(static_cast<std::size_t>(a) == OverAligned);
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
constexpr auto OverAligned = alignof(std::max_align_t) * 2;
bool A_constructed = false;
alignas(OverAligned) char DummyData[OverAligned];
-void* operator new(std::size_t s, std::align_val_t a) throw(std::bad_alloc)
+void* operator new(std::size_t s, std::align_val_t a) TEST_THROW_SPEC(std::bad_alloc)
{
assert(new_called == 0); // We already allocated
assert(s <= sizeof(DummyData));
return DummyData;
}
-void operator delete(void* p, std::align_val_t a) throw()
+void operator delete(void* p, std::align_val_t a) TEST_NOEXCEPT
{
assert(new_called == 1);
--new_called;
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
++new_called;
void* ret = std::malloc(s);
return ret;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
--new_called;
std::free(p);
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
++new_called;
void* ret = std::malloc(s);
return ret;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
--new_called;
std::free(p);
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete(void* p, std::size_t) throw()
+void operator delete(void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete(void* p, std::size_t) throw()
+void operator delete(void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int delete_called = 0;
int delete_nothrow_called = 0;
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++delete_nothrow_called;
std::free(p);
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete(void* p, std::size_t) throw()
+void operator delete(void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
MemCounter globalMemCounter((MemCounter::MemCounterCtorArg_()));
#ifndef DISABLE_NEW_COUNT
-void* operator new(std::size_t s)
-#if TEST_STD_VER < 11
- throw(std::bad_alloc)
-#endif
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
globalMemCounter.newCalled(s);
void* ret = std::malloc(s);
return ret;
}
-void operator delete(void* p)
-#if TEST_STD_VER < 11
- throw()
-#else
- noexcept
-#endif
+void operator delete(void* p) TEST_NOEXCEPT
{
globalMemCounter.deleteCalled(p);
std::free(p);
}
-void* operator new[](std::size_t s)
-#if TEST_STD_VER < 11
- throw(std::bad_alloc)
-#endif
+void* operator new[](std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
globalMemCounter.newArrayCalled(s);
return operator new(s);
}
-void operator delete[](void* p)
-#if TEST_STD_VER < 11
- throw()
-#else
- noexcept
-#endif
+void operator delete[](void* p) TEST_NOEXCEPT
{
globalMemCounter.deleteArrayCalled(p);
operator delete(p);
template <class U> struct rebind {typedef test_allocator<U> other;};
- test_allocator() throw() : data_(0) {++count;}
- explicit test_allocator(int i) throw() : data_(i) {++count;}
- test_allocator(const test_allocator& a) throw()
+ test_allocator() TEST_NOEXCEPT : data_(0) {++count;}
+ explicit test_allocator(int i) TEST_NOEXCEPT : data_(i) {++count;}
+ test_allocator(const test_allocator& a) TEST_NOEXCEPT
: data_(a.data_) {++count;}
- template <class U> test_allocator(const test_allocator<U>& a) throw()
+ template <class U> test_allocator(const test_allocator<U>& a) TEST_NOEXCEPT
: data_(a.data_) {++count;}
- ~test_allocator() throw() {assert(data_ >= 0); --count; data_ = -1;}
+ ~test_allocator() TEST_NOEXCEPT {assert(data_ >= 0); --count; data_ = -1;}
pointer address(reference x) const {return &x;}
const_pointer address(const_reference x) const {return &x;}
pointer allocate(size_type n, const void* = 0)
}
void deallocate(pointer p, size_type)
{assert(data_ >= 0); --alloc_count; ::operator delete((void*)p);}
- size_type max_size() const throw()
+ size_type max_size() const TEST_NOEXCEPT
{return UINT_MAX / sizeof(T);}
#if TEST_STD_VER < 11
void construct(pointer p, const T& val)
template <class U> struct rebind {typedef non_default_test_allocator<U> other;};
-// non_default_test_allocator() throw() : data_(0) {++count;}
- explicit non_default_test_allocator(int i) throw() : data_(i) {++count;}
- non_default_test_allocator(const non_default_test_allocator& a) throw()
+// non_default_test_allocator() TEST_NOEXCEPT : data_(0) {++count;}
+ explicit non_default_test_allocator(int i) TEST_NOEXCEPT : data_(i) {++count;}
+ non_default_test_allocator(const non_default_test_allocator& a) TEST_NOEXCEPT
: data_(a.data_) {++count;}
- template <class U> non_default_test_allocator(const non_default_test_allocator<U>& a) throw()
+ template <class U> non_default_test_allocator(const non_default_test_allocator<U>& a) TEST_NOEXCEPT
: data_(a.data_) {++count;}
- ~non_default_test_allocator() throw() {assert(data_ >= 0); --count; data_ = -1;}
+ ~non_default_test_allocator() TEST_NOEXCEPT {assert(data_ >= 0); --count; data_ = -1;}
pointer address(reference x) const {return &x;}
const_pointer address(const_reference x) const {return &x;}
pointer allocate(size_type n, const void* = 0)
}
void deallocate(pointer p, size_type)
{assert(data_ >= 0); --alloc_count; ::operator delete((void*)p); }
- size_type max_size() const throw()
+ size_type max_size() const TEST_NOEXCEPT
{return UINT_MAX / sizeof(T);}
#if TEST_STD_VER < 11
void construct(pointer p, const T& val)
template <class U> struct rebind {typedef test_allocator<U> other;};
- test_allocator() throw() : data_(0) {}
- explicit test_allocator(int i) throw() : data_(i) {}
- test_allocator(const test_allocator& a) throw()
+ test_allocator() TEST_NOEXCEPT : data_(0) {}
+ explicit test_allocator(int i) TEST_NOEXCEPT : data_(i) {}
+ test_allocator(const test_allocator& a) TEST_NOEXCEPT
: data_(a.data_) {}
- template <class U> test_allocator(const test_allocator<U>& a) throw()
+ template <class U> test_allocator(const test_allocator<U>& a) TEST_NOEXCEPT
: data_(a.data_) {}
- ~test_allocator() throw() {data_ = -1;}
+ ~test_allocator() TEST_NOEXCEPT {data_ = -1;}
friend bool operator==(const test_allocator& x, const test_allocator& y)
{return x.data_ == y.data_;}
#endif
#if TEST_STD_VER >= 11
+#define TEST_ALIGNOF(...) alignof(__VA_ARGS__)
+#define TEST_ALIGNAS(...) alignas(__VA_ARGS__)
#define TEST_CONSTEXPR constexpr
#define TEST_NOEXCEPT noexcept
#define TEST_NOEXCEPT_COND(...) noexcept(__VA_ARGS__)
# else
# define TEST_CONSTEXPR_CXX14
# endif
-#define TEST_ALIGNOF(...) alignof(__VA_ARGS__)
-#define TEST_ALIGNAS(...) alignas(__VA_ARGS__)
+# if TEST_STD_VER > 14
+# define TEST_THROW_SPEC(...)
+# else
+# define TEST_THROW_SPEC(...) throw(__VA_ARGS__)
+# endif
#else
+#define TEST_ALIGNOF(...) __alignof(__VA_ARGS__)
+#define TEST_ALIGNAS(...) __attribute__((__aligned__(__VA_ARGS__)))
#define TEST_CONSTEXPR
#define TEST_CONSTEXPR_CXX14
#define TEST_NOEXCEPT throw()
#define TEST_NOEXCEPT_COND(...)
-#define TEST_ALIGNOF(...) __alignof(__VA_ARGS__)
-#define TEST_ALIGNAS(...) __attribute__((__aligned__(__VA_ARGS__)))
+#define TEST_THROW_SPEC(...) throw(__VA_ARGS__)
#endif
#define TEST_ALIGNAS_TYPE(...) TEST_ALIGNAS(TEST_ALIGNOF(__VA_ARGS__))