From 13dd928ae18ef9610bc820b7b3e65629addea1d2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Jun 2016 18:50:51 +0200 Subject: Get rid of C++11 deprecation warnings for auto_ptr, exception specs In particular, std::auto_ptr is no longer mapped in C++11. --- odb/details/config-vc.h | 3 +++ odb/details/config.hxx | 10 ++++++++++ odb/details/meta/polymorphic-p.hxx | 3 ++- odb/details/posix/exceptions.cxx | 2 +- odb/details/posix/exceptions.hxx | 3 ++- odb/details/shared-ptr/base.cxx | 8 ++++++-- odb/details/shared-ptr/base.hxx | 20 +++++++++++++++++--- odb/details/shared-ptr/base.ixx | 18 ++++++++++++++++-- odb/details/shared-ptr/exception.hxx | 4 +++- odb/details/transfer-ptr.hxx | 26 +++++++++++++------------- odb/details/win32/exceptions.cxx | 2 +- odb/details/win32/exceptions.hxx | 5 +++-- 12 files changed, 77 insertions(+), 27 deletions(-) (limited to 'odb/details') diff --git a/odb/details/config-vc.h b/odb/details/config-vc.h index a7f8c95..c187fe5 100644 --- a/odb/details/config-vc.h +++ b/odb/details/config-vc.h @@ -24,6 +24,9 @@ # define ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT # define ODB_CXX11_VARIADIC_TEMPLATE # define ODB_CXX11_INITIALIZER_LIST +# if _MSC_VER >= 1900 +# define ODB_CXX11_NOEXCEPT +# endif # endif # endif #endif diff --git a/odb/details/config.hxx b/odb/details/config.hxx index c36b163..5aa35aa 100644 --- a/odb/details/config.hxx +++ b/odb/details/config.hxx @@ -16,6 +16,7 @@ # define ODB_CXX11 # if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 # define ODB_CXX11_NULLPTR +# define ODB_CXX11_NOEXCEPT # endif # define ODB_CXX11_DELETED_FUNCTION # define ODB_CXX11_EXPLICIT_CONVERSION_OPERATOR @@ -29,12 +30,15 @@ # define ODB_CXX11 # ifdef __clang__ // Pretends to be a really old __GNUC__ on some platforms. # define ODB_CXX11_NULLPTR +# define ODB_CXX11_NOEXCEPT # elif defined(__GNUC__) # if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4 # define ODB_CXX11_NULLPTR +# define ODB_CXX11_NOEXCEPT # endif # else # define ODB_CXX11_NULLPTR +# define ODB_CXX11_NOEXCEPT # endif # define ODB_CXX11_DELETED_FUNCTION # define ODB_CXX11_EXPLICIT_CONVERSION_OPERATOR @@ -48,6 +52,12 @@ # endif #endif +#ifdef ODB_CXX11_NOEXCEPT +# define ODB_NOTHROW_NOEXCEPT noexcept +#else +# define ODB_NOTHROW_NOEXCEPT throw() +#endif + // no post #endif // ODB_DETAILS_CONFIG_HXX diff --git a/odb/details/meta/polymorphic-p.hxx b/odb/details/meta/polymorphic-p.hxx index bd90fc2..5315afc 100644 --- a/odb/details/meta/polymorphic-p.hxx +++ b/odb/details/meta/polymorphic-p.hxx @@ -7,6 +7,7 @@ #include +#include // ODB_NOTHROW_NOEXCEPT #include #include @@ -40,7 +41,7 @@ namespace odb t2 (); virtual - ~t2 () throw (); + ~t2 () ODB_NOTHROW_NOEXCEPT; }; static const bool result = sizeof (t1) == sizeof (t2); diff --git a/odb/details/posix/exceptions.cxx b/odb/details/posix/exceptions.cxx index 0ed0aa3..ecffa4f 100644 --- a/odb/details/posix/exceptions.cxx +++ b/odb/details/posix/exceptions.cxx @@ -9,7 +9,7 @@ namespace odb namespace details { const char* posix_exception:: - what () const throw () + what () const ODB_NOTHROW_NOEXCEPT { return "POSIX API error"; } diff --git a/odb/details/posix/exceptions.hxx b/odb/details/posix/exceptions.hxx index dd78313..7a40ac6 100644 --- a/odb/details/posix/exceptions.hxx +++ b/odb/details/posix/exceptions.hxx @@ -7,6 +7,7 @@ #include +#include // ODB_NOTHROW_NOEXCEPT #include #include @@ -22,7 +23,7 @@ namespace odb code () const {return code_;} virtual const char* - what () const throw (); + what () const ODB_NOTHROW_NOEXCEPT; virtual posix_exception* clone () const; diff --git a/odb/details/shared-ptr/base.cxx b/odb/details/shared-ptr/base.cxx index b95797b..5bfc0af 100644 --- a/odb/details/shared-ptr/base.cxx +++ b/odb/details/shared-ptr/base.cxx @@ -15,7 +15,7 @@ namespace odb share exclusive = share (2); const char* not_shared:: - what () const throw () + what () const ODB_NOTHROW_NOEXCEPT { return "object is not shared"; } @@ -54,7 +54,11 @@ namespace odb } void* +#ifdef ODB_CXX11 +operator new (size_t n, odb::details::share s) +#else operator new (size_t n, odb::details::share s) throw (std::bad_alloc) +#endif { if (s == odb::details::shared) { @@ -74,7 +78,7 @@ operator new (size_t n, odb::details::share s) throw (std::bad_alloc) } void -operator delete (void* p, odb::details::share s) throw () +operator delete (void* p, odb::details::share s) ODB_NOTHROW_NOEXCEPT { // This version of operator delete is only called when the c-tor // fails. In this case there is no object and we can just free the diff --git a/odb/details/shared-ptr/base.hxx b/odb/details/shared-ptr/base.hxx index 4a38945..90053e8 100644 --- a/odb/details/shared-ptr/base.hxx +++ b/odb/details/shared-ptr/base.hxx @@ -10,6 +10,7 @@ #include #include // std::size_t +#include // ODB_CXX11, ODB_NOTHROW_NOEXCEPT #include #include @@ -34,11 +35,16 @@ namespace odb } } +#ifdef ODB_CXX11 +LIBODB_EXPORT void* +operator new (std::size_t, odb::details::share); +#else LIBODB_EXPORT void* operator new (std::size_t, odb::details::share) throw (std::bad_alloc); +#endif LIBODB_EXPORT void -operator delete (void*, odb::details::share) throw (); +operator delete (void*, odb::details::share) ODB_NOTHROW_NOEXCEPT; namespace odb { @@ -61,17 +67,25 @@ namespace odb std::size_t _ref_count () const; +#ifdef ODB_CXX11 + void* + operator new (std::size_t); + + void* + operator new (std::size_t, share); +#else void* operator new (std::size_t) throw (std::bad_alloc); void* operator new (std::size_t, share) throw (std::bad_alloc); +#endif void - operator delete (void*, share) throw (); + operator delete (void*, share) ODB_NOTHROW_NOEXCEPT; void - operator delete (void*) throw (); + operator delete (void*) ODB_NOTHROW_NOEXCEPT; struct refcount_callback { diff --git a/odb/details/shared-ptr/base.ixx b/odb/details/shared-ptr/base.ixx index 9bf7c94..3ed1339 100644 --- a/odb/details/shared-ptr/base.ixx +++ b/odb/details/shared-ptr/base.ixx @@ -63,6 +63,19 @@ namespace odb return counter_; } +#ifdef ODB_CXX11 + inline void* shared_base:: + operator new (std::size_t n) + { + return ::operator new (n); + } + + inline void* shared_base:: + operator new (std::size_t n, share) + { + return ::operator new (n); + } +#else inline void* shared_base:: operator new (std::size_t n) throw (std::bad_alloc) { @@ -74,15 +87,16 @@ namespace odb { return ::operator new (n); } +#endif inline void shared_base:: - operator delete (void* p, share) throw () + operator delete (void* p, share) ODB_NOTHROW_NOEXCEPT { ::operator delete (p); } inline void shared_base:: - operator delete (void* p) throw () + operator delete (void* p) ODB_NOTHROW_NOEXCEPT { ::operator delete (p); } diff --git a/odb/details/shared-ptr/exception.hxx b/odb/details/shared-ptr/exception.hxx index 99ed069..a006a35 100644 --- a/odb/details/shared-ptr/exception.hxx +++ b/odb/details/shared-ptr/exception.hxx @@ -8,6 +8,8 @@ #include #include + +#include // ODB_NOTHROW_NOEXCEPT #include namespace odb @@ -17,7 +19,7 @@ namespace odb struct LIBODB_EXPORT not_shared: exception { virtual const char* - what () const throw (); + what () const ODB_NOTHROW_NOEXCEPT; virtual not_shared* clone () const; diff --git a/odb/details/transfer-ptr.hxx b/odb/details/transfer-ptr.hxx index 13f113e..0e2d726 100644 --- a/odb/details/transfer-ptr.hxx +++ b/odb/details/transfer-ptr.hxx @@ -23,10 +23,22 @@ namespace odb transfer_ptr (): p_ (0) {} +#ifndef ODB_CXX11 template transfer_ptr (std::auto_ptr p): p_ (p.release ()) {} -#ifdef ODB_CXX11 + private: + transfer_ptr& operator= (const transfer_ptr&); + + public: + // In our usage transfer_ptr is always created implicitly and + // never const. So while this is not very clean, it is legal. + // Plus it will all go away once we drop C++98 (I can hardly + // wait). + // + transfer_ptr (const transfer_ptr& p) + : p_ (const_cast (p).transfer ()) {} +#else #ifdef ODB_CXX11_NULLPTR transfer_ptr (std::nullptr_t): p_ (0) {} #endif @@ -39,18 +51,6 @@ namespace odb public: transfer_ptr (transfer_ptr&& p): p_ (p.transfer ()) {} -#else - private: - transfer_ptr& operator= (const transfer_ptr&); - - public: - // In our usage transfer_ptr is always created implicitly and - // never const. So while this is not very clean, it is legal. - // Plus it will all go away once we drop C++98 (I can hardly - // wait). - // - transfer_ptr (const transfer_ptr& p) - : p_ (const_cast (p).transfer ()) {} #endif ~transfer_ptr () {delete p_;} diff --git a/odb/details/win32/exceptions.cxx b/odb/details/win32/exceptions.cxx index 0e52348..1067a28 100644 --- a/odb/details/win32/exceptions.cxx +++ b/odb/details/win32/exceptions.cxx @@ -9,7 +9,7 @@ namespace odb namespace details { const char* win32_exception:: - what () const throw () + what () const ODB_NOTHROW_NOEXCEPT { return "Win32 API error"; } diff --git a/odb/details/win32/exceptions.hxx b/odb/details/win32/exceptions.hxx index 7303bb7..1f8a4b2 100644 --- a/odb/details/win32/exceptions.hxx +++ b/odb/details/win32/exceptions.hxx @@ -7,9 +7,10 @@ #include -#include +#include // ODB_NOTHROW_NOEXCEPT #include #include +#include namespace odb { @@ -24,7 +25,7 @@ namespace odb code () const {return code_;} virtual const char* - what () const throw (); + what () const ODB_NOTHROW_NOEXCEPT; virtual win32_exception* clone () const; -- cgit v1.1