From 7618080ac6e531ec5da434a3f6f1ed0cb7a7f99d Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Fri, 1 Nov 2019 23:21:51 +0100 Subject: [PATCH] Delete allocation and deallocation operators that are forbidden. This also avoids compiler warnings about non-throwing exception specifications. --- include/cln/string.h | 4 ++-- src/vector/cl_GV_I.cc | 8 ++++---- src/vector/cl_GV_number.cc | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/cln/string.h b/include/cln/string.h index 683e0bc..e61c6ca 100644 --- a/include/cln/string.h +++ b/include/cln/string.h @@ -18,9 +18,9 @@ private: unsigned long length; // length (in characters) char data[1]; // the characters, plus a '\0' at the end // Standard allocation disabled. - void* operator new (size_t size) { (void)size; throw runtime_exception(); } + void* operator new (size_t size) = delete; // Standard deallocation disabled. - void operator delete (void* ptr) { (void)ptr; throw runtime_exception(); } + void operator delete (void* ptr) = delete; // No default constructor. cl_heap_string (); private: diff --git a/src/vector/cl_GV_I.cc b/src/vector/cl_GV_I.cc index 624388b..328b31b 100644 --- a/src/vector/cl_GV_I.cc +++ b/src/vector/cl_GV_I.cc @@ -69,9 +69,9 @@ static inline cl_GV_I_vectorops* outcast (cl_GV_vectorops* vectorops) struct cl_heap_GV_I_general : public cl_heap_GV_I { cl_I data[1]; // Standard allocation disabled. - void* operator new (size_t size) { unused size; throw runtime_exception(); } + void* operator new (size_t size) = delete; // Standard deallocation disabled. - void operator delete (void* ptr) { unused ptr; throw runtime_exception(); } + void operator delete (void* ptr) = delete; // No default constructor. cl_heap_GV_I_general (); }; @@ -139,9 +139,9 @@ cl_heap_GV_I* cl_make_heap_GV_I (std::size_t len) struct cl_heap_GV_I_bits##m : public cl_heap_GV_I { \ uint_t data[1]; \ /* Standard allocation disabled. */ \ - void* operator new (size_t size) { unused size; throw runtime_exception(); } \ + void* operator new (size_t size) = delete; \ /* Standard deallocation disabled. */ \ - void operator delete (void* ptr) { unused ptr; throw runtime_exception(); } \ + void operator delete (void* ptr) = delete; \ /* No default constructor. */ \ cl_heap_GV_I_bits##m (); \ }; \ diff --git a/src/vector/cl_GV_number.cc b/src/vector/cl_GV_number.cc index fc19449..3a70ba6 100644 --- a/src/vector/cl_GV_number.cc +++ b/src/vector/cl_GV_number.cc @@ -45,9 +45,9 @@ static inline const cl_heap_GV_number * outcast (const cl_GV_inner* v struct cl_heap_GV_number_general : public cl_heap_GV_number { cl_number data[1]; // Standard allocation disabled. - void* operator new (size_t size) { unused size; throw runtime_exception(); } + void* operator new (size_t size) = delete; // Standard deallocation disabled. - void operator delete (void* ptr) { unused ptr; throw runtime_exception(); } + void operator delete (void* ptr) = delete; // No default constructor. cl_heap_GV_number_general (); }; -- 2.49.0