diff options
Diffstat (limited to 'Swiften/Base')
-rw-r--r-- | Swiften/Base/API.h | 19 | ||||
-rw-r--r-- | Swiften/Base/Error.h | 4 | ||||
-rw-r--r-- | Swiften/Base/SafeAllocator.h | 14 |
3 files changed, 29 insertions, 8 deletions
diff --git a/Swiften/Base/API.h b/Swiften/Base/API.h index 388ad0a..0913181 100644 --- a/Swiften/Base/API.h +++ b/Swiften/Base/API.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2013 Remko Tronçon + * Copyright (c) 2012-2014 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -7,6 +7,7 @@ #pragma once #include <Swiften/Base/Platform.h> +#include <boost/config.hpp> #ifdef SWIFTEN_STATIC # define SWIFTEN_API @@ -23,3 +24,19 @@ # define SWIFTEN_API # endif #endif + +#ifdef BOOST_NO_DEFAULTED_FUNCTIONS +# define SWIFTEN_DEFAULT_COPY_CONSTRUCTOR(cls) +# define SWIFTEN_DEFAULT_COPY_ASSIGMNENT_OPERATOR(cls) +#else +# define SWIFTEN_DEFAULT_COPY_CONSTRUCTOR(cls) \ + cls(const cls&) = default; +# define SWIFTEN_DEFAULT_COPY_ASSIGMNENT_OPERATOR(cls) \ + cls& operator=(const cls&) = default; +#endif + +#ifdef BOOST_NO_NOEXCEPT +#define SWIFTEN_NOEXCEPT throw() +#else +#define SWIFTEN_NOEXCEPT noexcept +#endif diff --git a/Swiften/Base/Error.h b/Swiften/Base/Error.h index d9f3b91..00287fc 100644 --- a/Swiften/Base/Error.h +++ b/Swiften/Base/Error.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2014 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -11,6 +11,8 @@ namespace Swift { class SWIFTEN_API Error { public: + Error() {} + SWIFTEN_DEFAULT_COPY_CONSTRUCTOR(Error) virtual ~Error(); }; } diff --git a/Swiften/Base/SafeAllocator.h b/Swiften/Base/SafeAllocator.h index b01d77d..8a8b25e 100644 --- a/Swiften/Base/SafeAllocator.h +++ b/Swiften/Base/SafeAllocator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2013 Remko Tronçon + * Copyright (c) 2011-2014 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -9,6 +9,8 @@ #include <vector> #include <algorithm> +#include <Swiften/Base/API.h> + namespace Swift { void secureZeroMemory(char* memory, size_t numberOfBytes); @@ -19,16 +21,16 @@ namespace Swift { typedef SafeAllocator<U> other; }; - SafeAllocator() throw() {} - SafeAllocator(const SafeAllocator&) throw() : std::allocator<T>() {} - template <class U> SafeAllocator(const SafeAllocator<U>&) throw() {} - ~SafeAllocator() throw() {} + SafeAllocator() SWIFTEN_NOEXCEPT {} + SafeAllocator(const SafeAllocator&) SWIFTEN_NOEXCEPT : std::allocator<T>() {} + template <class U> SafeAllocator(const SafeAllocator<U>&) SWIFTEN_NOEXCEPT {} + ~SafeAllocator() SWIFTEN_NOEXCEPT {} void deallocate (T* p, size_t num) { secureZeroMemory(reinterpret_cast<char*>(p), num); std::allocator<T>::deallocate(p, num); } - private: + SWIFTEN_DEFAULT_COPY_ASSIGMNENT_OPERATOR(SafeAllocator) }; } |