From: Michael Wallner Date: Mon, 6 Jan 2020 11:17:34 +0000 (+0100) Subject: c++: fix C++11 compatibility X-Git-Tag: pre_cmake~91 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=74d60e0cbacf53e996e9a72b644e30ed7efa3835;p=m6w6%2Flibmemcached c++: fix C++11 compatibility - auto_ptr has been deprecated - destructors are noexcept by default --- diff --git a/libtest/main.cc b/libtest/main.cc index 3084ca4b..b93f7570 100644 --- a/libtest/main.cc +++ b/libtest/main.cc @@ -60,6 +60,12 @@ #pragma GCC diagnostic ignored "-Wold-style-cast" #endif +#if __cplusplus >= 201103L +# define UNIQUE_PTR std::unique_ptr +#else +# define UNIQUE_PTR std::auto_ptr +#endif + using namespace libtest; static void stats_print(libtest::Framework *frame) @@ -297,7 +303,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - std::auto_ptr frame(new libtest::Framework(signal, binary_name, collection_to_run, wildcard)); + UNIQUE_PTR frame(new libtest::Framework(signal, binary_name, collection_to_run, wildcard)); // Run create(), bail on error. { diff --git a/libtest/thread.hpp b/libtest/thread.hpp index b09da7fc..640cb66a 100644 --- a/libtest/thread.hpp +++ b/libtest/thread.hpp @@ -38,6 +38,10 @@ #include +#if __cplusplus < 201103L +# define noexcept(a) +#endif + namespace libtest { namespace thread @@ -52,7 +56,7 @@ public: _err= pthread_mutex_init(&_mutex, NULL); } - ~Mutex() + ~Mutex() noexcept(false) { if ((_err= pthread_mutex_destroy(&_mutex))) { @@ -84,7 +88,7 @@ public: init(); } - ~ScopedLock() + ~ScopedLock() noexcept(false) { int err; if ((err= pthread_mutex_unlock(_mutex.handle()))) @@ -124,7 +128,7 @@ public: } } - ~Condition() + ~Condition() noexcept(false) { int err; if ((err= pthread_cond_destroy(&_cond)))