]> www.ginac.de Git - cln.git/commitdiff
Delete allocation and deallocation operators that are forbidden.
authorRichard Kreckel <kreckel@ginac.de>
Fri, 1 Nov 2019 22:21:51 +0000 (23:21 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Fri, 1 Nov 2019 22:23:59 +0000 (23:23 +0100)
This also avoids compiler warnings about non-throwing exception
specifications.

include/cln/string.h
src/vector/cl_GV_I.cc
src/vector/cl_GV_number.cc

index 683e0bc83ab75efca19306cf48c721f7bed00d00..e61c6cad626917bcfc44706e9435d3e6cf73c491 100644 (file)
@@ -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:
index 624388bcf588748b57448d5d568d230029b7c5d3..328b31b4c6c237496130d332d184fe8042c404e5 100644 (file)
@@ -69,9 +69,9 @@ static inline cl_GV_I_vectorops* outcast (cl_GV_vectorops<cl_I>* 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 ();                                        \
 };                                                                     \
index fc19449a35e365060d7bd29a4180133b77e0b3b3..3a70ba6b0afd424d13ede4c25053937a002ede5b 100644 (file)
@@ -45,9 +45,9 @@ static inline const cl_heap_GV_number * outcast (const cl_GV_inner<cl_number>* 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 ();
 };