diff --git a/beast/ByteOrder.h b/beast/ByteOrder.h index 2bd069388d..6577d616cf 100644 --- a/beast/ByteOrder.h +++ b/beast/ByteOrder.h @@ -25,7 +25,6 @@ #define BEAST_BYTEORDER_H_INCLUDED #include -#include #include @@ -35,7 +34,7 @@ namespace beast { /** Contains static methods for converting the byte order between different endiannesses. */ -class ByteOrder : public Uncopyable +class ByteOrder { public: //============================================================================== @@ -105,6 +104,8 @@ public: private: ByteOrder(); + ByteOrder(ByteOrder const&) = delete; + ByteOrder& operator= (ByteOrder const&) = delete; }; //============================================================================== diff --git a/beast/HeapBlock.h b/beast/HeapBlock.h index cbbe097cf6..045fba5630 100644 --- a/beast/HeapBlock.h +++ b/beast/HeapBlock.h @@ -29,7 +29,6 @@ #include #include -#include // If the MSVC debug heap headers were included, disable // the macros during the juce include since they conflict. @@ -122,7 +121,7 @@ namespace HeapBlockHelper @see Array, MemoryBlock */ template -class HeapBlock : public Uncopyable +class HeapBlock { public: //============================================================================== @@ -136,12 +135,6 @@ public: { } - HeapBlock (HeapBlock& other) - { - data = other.data; - other.data = nullptr; - } - /** Creates a HeapBlock containing a number of elements. The contents of the block are undefined, as it will have been created by a @@ -169,6 +162,10 @@ public: throwOnAllocationFailure(); } + + HeapBlock(HeapBlock const&) = delete; + HeapBlock& operator= (HeapBlock const&) = delete; + /** Destructor. This will free the data, if any has been allocated. */ diff --git a/beast/Memory.h b/beast/Memory.h index 49ff62c89f..067242f9ba 100644 --- a/beast/Memory.h +++ b/beast/Memory.h @@ -27,7 +27,6 @@ #include #include -#include namespace beast { @@ -78,12 +77,16 @@ Type* createCopyIfNotNull (const Type* pointer) /** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII. You should use the BEAST_AUTORELEASEPOOL macro to create a local auto-release pool on the stack. */ - class ScopedAutoReleasePool : public Uncopyable + class ScopedAutoReleasePool { public: ScopedAutoReleasePool(); ~ScopedAutoReleasePool(); + + ScopedAutoReleasePool(ScopedAutoReleasePool const&) = delete; + ScopedAutoReleasePool& operator= (ScopedAutoReleasePool const&) = delete; + private: void* pool; }; diff --git a/beast/Uncopyable.h b/beast/Uncopyable.h deleted file mode 100644 index 20a41770ba..0000000000 --- a/beast/Uncopyable.h +++ /dev/null @@ -1,77 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNCOPYABLE_H_INCLUDED -#define BEAST_UNCOPYABLE_H_INCLUDED - -namespace beast -{ - -// Ideas from boost - -/** Prevent copy construction and assignment. - - This is used to suppress warnings and prevent unsafe operations on - objects which cannot be passed by value. Ideas based on Boost. - - For example, instead of - - @code - - class MyClass - { - public: - //... - - private: - MyClass (const MyClass&); - MyClass& operator= (const MyClass&); - }; - - @endcode - - ..you can just write: - - @code - - class MyClass : public Uncopyable - { - public: - //... - }; - - @endcode - - @note The derivation should be public or else child classes which - also derive from Uncopyable may not compile. -*/ -class Uncopyable -{ -protected: - Uncopyable () { } - ~Uncopyable () { } - -private: - Uncopyable (Uncopyable const&); - Uncopyable const& operator= (Uncopyable const&); -}; - -} - -#endif diff --git a/beast/intrusive/List.h b/beast/intrusive/List.h index 3f4e01aa6a..6005eea2fb 100644 --- a/beast/intrusive/List.h +++ b/beast/intrusive/List.h @@ -21,7 +21,6 @@ #define BEAST_INTRUSIVE_LIST_H_INCLUDED #include -#include #include #include @@ -265,7 +264,7 @@ private: @ingroup beast_core intrusive */ template -class List : public Uncopyable +class List { public: typedef typename detail::ListNode Node; @@ -289,6 +288,9 @@ public: clear (); } + List(List const&) = delete; + List& operator= (List const&) = delete; + /** Determine if the list is empty. @return `true` if the list is empty. */ diff --git a/beast/intrusive/LockFreeStack.h b/beast/intrusive/LockFreeStack.h index 519ca80305..34fa85ccb7 100644 --- a/beast/intrusive/LockFreeStack.h +++ b/beast/intrusive/LockFreeStack.h @@ -21,7 +21,6 @@ #define BEAST_INTRUSIVE_LOCKFREESTACK_H_INCLUDED #include -#include #include #include @@ -142,15 +141,16 @@ bool operator!= (LockFreeStackIterator const& lhs, omitted, the default tag is used. */ template -class LockFreeStack : public Uncopyable +class LockFreeStack { public: - class Node : public Uncopyable + class Node { public: - Node () - { - } + Node () = default; + + Node(Node const&) = delete; + Node& operator= (Node const&) = delete; explicit Node (Node* next) : m_next (next) { @@ -184,6 +184,9 @@ public: { } + LockFreeStack(LockFreeStack const&) = delete; + LockFreeStack& operator= (LockFreeStack const&) = delete; + /** Returns true if the stack is empty. */ bool empty() const { diff --git a/beast/module/asio/basics/SSLContext.h b/beast/module/asio/basics/SSLContext.h index 8310914aa3..dabe56b196 100644 --- a/beast/module/asio/basics/SSLContext.h +++ b/beast/module/asio/basics/SSLContext.h @@ -20,7 +20,6 @@ #ifndef BEAST_ASIO_BASICS_SSLCONTEXT_H_INCLUDED #define BEAST_ASIO_BASICS_SSLCONTEXT_H_INCLUDED -#include #include namespace beast { @@ -29,7 +28,7 @@ namespace asio { /** Simple base class for passing a context around. This lets derived classes hide their implementation from the headers. */ -class SSLContext : public Uncopyable +class SSLContext { public: virtual ~SSLContext (); @@ -61,6 +60,9 @@ public: protected: explicit SSLContext (ContextType& context); + SSLContext(SSLContext const&) = delete; + SSLContext& operator= (SSLContext const&) = delete; + ContextType& m_context; }; diff --git a/beast/module/asio/http/HTTPClientType.cpp b/beast/module/asio/http/HTTPClientType.cpp index a7ba129447..a25159c117 100644 --- a/beast/module/asio/http/HTTPClientType.cpp +++ b/beast/module/asio/http/HTTPClientType.cpp @@ -26,7 +26,7 @@ namespace beast { namespace asio { -class HTTPClientType : public HTTPClientBase, public Uncopyable +class HTTPClientType : public HTTPClientBase { public: class Session; @@ -61,6 +61,9 @@ public: { } + HTTPClientType(HTTPClientType const&) = delete; + HTTPClientType& operator= (HTTPClientType const&) = delete; + ~HTTPClientType () { cancel(); diff --git a/beast/module/core/containers/LinkedListPointer.h b/beast/module/core/containers/LinkedListPointer.h index 046434ddc4..ea3bf557a7 100644 --- a/beast/module/core/containers/LinkedListPointer.h +++ b/beast/module/core/containers/LinkedListPointer.h @@ -55,7 +55,7 @@ namespace beast @endcode */ template -class LinkedListPointer : public Uncopyable +class LinkedListPointer { public: //============================================================================== @@ -65,6 +65,9 @@ public: { } + LinkedListPointer(LinkedListPointer const&) = delete; + LinkedListPointer& operator= (LinkedListPointer const&) = delete; + /** Creates a pointer to a list whose head is the item provided. */ explicit LinkedListPointer (ObjectType* const headItem) noexcept : item (headItem) @@ -332,7 +335,7 @@ public: list, and then repeatedly call Appender::append() to add items to the end of the list in O(1) time. */ - class Appender : public Uncopyable + class Appender { public: /** Creates an appender which will add items to the given list. @@ -344,6 +347,9 @@ public: bassert (endOfListPointer.item == nullptr); } + Appender(LinkedListPointer const&) = delete; + Appender& operator= (Appender const&) = delete; + /** Appends an item to the list. */ void append (ObjectType* const newItem) noexcept { diff --git a/beast/module/core/containers/ScopedValueSetter.h b/beast/module/core/containers/ScopedValueSetter.h index 254268769f..f1c82f352a 100644 --- a/beast/module/core/containers/ScopedValueSetter.h +++ b/beast/module/core/containers/ScopedValueSetter.h @@ -54,7 +54,7 @@ namespace beast */ template -class ScopedValueSetter : public Uncopyable +class ScopedValueSetter { public: /** Creates a ScopedValueSetter that will immediately change the specified value to the @@ -80,6 +80,9 @@ public: valueToSet = newValue; } + ScopedValueSetter(ScopedValueSetter const&) = delete; + ScopedValueSetter& operator= (ScopedValueSetter const&) = delete; + ~ScopedValueSetter() { value = originalValue; diff --git a/beast/module/core/core.h b/beast/module/core/core.h index f720550114..fccd3a50cb 100644 --- a/beast/module/core/core.h +++ b/beast/module/core/core.h @@ -42,7 +42,6 @@ // New header-only library modeled more closely according to boost #include #include -#include #include #include #include diff --git a/beast/module/core/diagnostic/FatalError.h b/beast/module/core/diagnostic/FatalError.h index 70e75adf21..5adb21a4fd 100644 --- a/beast/module/core/diagnostic/FatalError.h +++ b/beast/module/core/diagnostic/FatalError.h @@ -34,7 +34,7 @@ namespace beast the process is terminated, a listener object gets notified so that the client application can perform logging or emit further diagnostics. */ -class FatalError : public Uncopyable +class FatalError { public: struct Reporter @@ -145,6 +145,9 @@ public: */ FatalError (char const* message, char const* filePath, int lineNumber); + FatalError(FatalError const&) = delete; + FatalError& operator= (FatalError const&) = delete; + private: static Reporter* s_reporter; }; diff --git a/beast/module/core/files/DirectoryIterator.h b/beast/module/core/files/DirectoryIterator.h index 10b9cc8b96..a002368286 100644 --- a/beast/module/core/files/DirectoryIterator.h +++ b/beast/module/core/files/DirectoryIterator.h @@ -41,7 +41,7 @@ namespace beast { It can also guess how far it's got using a wildly inaccurate algorithm. */ -class DirectoryIterator : LeakChecked , public Uncopyable +class DirectoryIterator : LeakChecked { public: //============================================================================== @@ -72,6 +72,9 @@ public: const String& wildCard = "*", int whatToLookFor = File::findFiles); + DirectoryIterator(DirectoryIterator const&) = delete; + DirectoryIterator& operator= (DirectoryIterator const&) = delete; + /** Destructor. */ ~DirectoryIterator(); @@ -116,10 +119,14 @@ public: private: //============================================================================== - class NativeIterator : LeakChecked , public Uncopyable + class NativeIterator : LeakChecked { public: NativeIterator (const File& directory, const String& wildCard); + + NativeIterator(NativeIterator const&) = delete; + NativeIterator& operator= (NativeIterator const&) = delete; + ~NativeIterator(); bool next (String& filenameFound, diff --git a/beast/module/core/files/RandomAccessFile.h b/beast/module/core/files/RandomAccessFile.h index 509f2146c8..673a366b94 100644 --- a/beast/module/core/files/RandomAccessFile.h +++ b/beast/module/core/files/RandomAccessFile.h @@ -39,7 +39,7 @@ namespace beast @see FileInputStream, FileOutputStream */ -class RandomAccessFile : public Uncopyable, LeakChecked +class RandomAccessFile : LeakChecked { public: /** The type of an FileOffset. @@ -71,6 +71,9 @@ public: */ RandomAccessFile () noexcept; + RandomAccessFile(RandomAccessFile const&) = delete; + RandomAccessFile& operator= (RandomAccessFile const&) = delete; + /** Destroy the file object. If the operating system file is open it will be closed. diff --git a/beast/module/core/files/TemporaryFile.h b/beast/module/core/files/TemporaryFile.h index 1c47c7ccc5..7b1d3ed16d 100644 --- a/beast/module/core/files/TemporaryFile.h +++ b/beast/module/core/files/TemporaryFile.h @@ -65,7 +65,7 @@ namespace beast @see File, FileOutputStream */ -class TemporaryFile : LeakChecked , public Uncopyable +class TemporaryFile : LeakChecked { public: //============================================================================== @@ -117,6 +117,9 @@ public: TemporaryFile (const File& targetFile, const File& temporaryFile); + TemporaryFile(TemporaryFile const&) = delete; + TemporaryFile& operator= (TemporaryFile const&) = delete; + /** Destructor. When this object is deleted it will make sure that its temporary file is diff --git a/beast/module/core/memory/SharedSingleton.h b/beast/module/core/memory/SharedSingleton.h index a42ee424be..c7bc82ec3f 100644 --- a/beast/module/core/memory/SharedSingleton.h +++ b/beast/module/core/memory/SharedSingleton.h @@ -169,7 +169,7 @@ private: // This structure gets zero-filled at static initialization time. // No constructors are called. // - class StaticData : public Uncopyable + class StaticData { public: LockType mutex; @@ -177,9 +177,10 @@ private: SharedSingleton object; bool destructorCalled; - private: - StaticData(); - ~StaticData(); + StaticData() = delete; + StaticData(StaticData const&) = delete; + StaticData& operator= (StaticData const&) = delete; + ~StaticData() = delete; }; static StaticData& getStaticData () diff --git a/beast/module/core/misc/WindowsRegistry.h b/beast/module/core/misc/WindowsRegistry.h index 2612d7755a..a9a7e13b26 100644 --- a/beast/module/core/misc/WindowsRegistry.h +++ b/beast/module/core/misc/WindowsRegistry.h @@ -33,7 +33,7 @@ namespace beast Contains some static helper functions for manipulating the MS Windows registry (Only available on Windows, of course!) */ -class WindowsRegistry : public Uncopyable +class WindowsRegistry { public: //============================================================================== @@ -113,8 +113,9 @@ public: int iconResourceNumber, bool registerForCurrentUserOnly); -private: - WindowsRegistry(); + WindowsRegistry() = delete; + WindowsRegistry(WindowsRegistry const&) = delete; + WindowsRegistry const& operator= (WindowsRegistry const&) = delete; }; #endif diff --git a/beast/module/core/native/bsd_Files.cpp b/beast/module/core/native/bsd_Files.cpp index 9e5d7884b8..e0eac389ef 100644 --- a/beast/module/core/native/bsd_Files.cpp +++ b/beast/module/core/native/bsd_Files.cpp @@ -244,7 +244,7 @@ bool File::moveToTrash() const } //============================================================================== -class DirectoryIterator::NativeIterator::Pimpl : public Uncopyable +class DirectoryIterator::NativeIterator::Pimpl { public: Pimpl (const File& directory, const String& wildCard_) @@ -254,6 +254,9 @@ public: { } + Pimpl (Pimpl const&) = delete; + Pimpl& operator= (Pimpl const&) = delete; + ~Pimpl() { if (dir != nullptr) diff --git a/beast/module/core/native/linux_Files.cpp b/beast/module/core/native/linux_Files.cpp index 11551684c9..c3311df117 100644 --- a/beast/module/core/native/linux_Files.cpp +++ b/beast/module/core/native/linux_Files.cpp @@ -244,7 +244,7 @@ bool File::moveToTrash() const } //============================================================================== -class DirectoryIterator::NativeIterator::Pimpl : public Uncopyable +class DirectoryIterator::NativeIterator::Pimpl { public: Pimpl (const File& directory, const String& wildCard_) @@ -254,6 +254,9 @@ public: { } + Pimpl (Pimpl const&) = delete; + Pimpl& operator= (Pimpl const&) = delete; + ~Pimpl() { if (dir != nullptr) diff --git a/beast/module/core/native/mac_Files.mm b/beast/module/core/native/mac_Files.mm index 71eb1c52cb..4352a2f3ba 100644 --- a/beast/module/core/native/mac_Files.mm +++ b/beast/module/core/native/mac_Files.mm @@ -312,7 +312,7 @@ bool File::moveToTrash() const } //============================================================================== -class DirectoryIterator::NativeIterator::Pimpl : public Uncopyable +class DirectoryIterator::NativeIterator::Pimpl { public: Pimpl (const File& directory, const String& wildCard_) @@ -326,6 +326,9 @@ public: } } + Pimpl (Pimpl const&) = delete; + Pimpl& operator= (Pimpl const&) = delete; + ~Pimpl() { [enumerator release]; diff --git a/beast/module/core/native/osx_ObjCHelpers.h b/beast/module/core/native/osx_ObjCHelpers.h index 14f8186cad..94d972b4ed 100644 --- a/beast/module/core/native/osx_ObjCHelpers.h +++ b/beast/module/core/native/osx_ObjCHelpers.h @@ -66,13 +66,16 @@ struct NSObjectRetainer //============================================================================== template -struct ObjCClass : public Uncopyable +struct ObjCClass { ObjCClass (const char* nameRoot) : cls (objc_allocateClassPair ([SuperclassType class], getRandomisedName (nameRoot).toUTF8(), 0)) { } + ObjCClass (ObjCClass const&); + ObjCClass& operator= (ObjCClass const&); + ~ObjCClass() { objc_disposeClassPair (cls); diff --git a/beast/module/core/native/win32_Files.cpp b/beast/module/core/native/win32_Files.cpp index 87d8bd094a..192d2da253 100644 --- a/beast/module/core/native/win32_Files.cpp +++ b/beast/module/core/native/win32_Files.cpp @@ -735,7 +735,6 @@ bool File::createLink (const String& description, const File& linkFileToCreate) //============================================================================== class DirectoryIterator::NativeIterator::Pimpl : LeakChecked - , public Uncopyable { public: Pimpl (const File& directory, const String& wildCard) @@ -744,6 +743,9 @@ public: { } + Pimpl (Pimpl const&) = delete; + Pimpl& operator= (Pimpl const&) = delete; + ~Pimpl() { if (handle != INVALID_HANDLE_VALUE) diff --git a/beast/module/core/native/win32_Registry.cpp b/beast/module/core/native/win32_Registry.cpp index 34d9c43790..302009f644 100644 --- a/beast/module/core/native/win32_Registry.cpp +++ b/beast/module/core/native/win32_Registry.cpp @@ -24,7 +24,7 @@ namespace beast { -struct RegistryKeyWrapper : public Uncopyable +struct RegistryKeyWrapper { RegistryKeyWrapper (String name, const bool createForWriting, const DWORD wow64Flags) : key (0), wideCharValueName (nullptr) @@ -55,6 +55,9 @@ struct RegistryKeyWrapper : public Uncopyable } } + RegistryKeyWrapper (RegistryKeyWrapper const&) = delete; + RegistryKeyWrapper& operator= (RegistryKeyWrapper const&) = delete; + ~RegistryKeyWrapper() { if (key != 0) diff --git a/beast/module/core/streams/FileInputSource.h b/beast/module/core/streams/FileInputSource.h index 77fc835d71..21812c5ae3 100644 --- a/beast/module/core/streams/FileInputSource.h +++ b/beast/module/core/streams/FileInputSource.h @@ -36,7 +36,6 @@ namespace beast class FileInputSource : public InputSource , LeakChecked - , public Uncopyable { public: //============================================================================== @@ -47,6 +46,9 @@ public: */ FileInputSource (const File& file, bool useFileTimeInHashGeneration = false); + FileInputSource (FileInputSource const&) = delete; + FileInputSource& operator= (FileInputSource const&) = delete; + /** Destructor. */ ~FileInputSource(); diff --git a/beast/module/core/streams/InputStream.h b/beast/module/core/streams/InputStream.h index ff6750ebc5..24fa416089 100644 --- a/beast/module/core/streams/InputStream.h +++ b/beast/module/core/streams/InputStream.h @@ -38,7 +38,6 @@ class MemoryBlock; @see OutputStream, FileInputStream */ class InputStream - : public Uncopyable , LeakChecked { public: @@ -352,7 +351,9 @@ public: protected: //============================================================================== - InputStream() noexcept {} + InputStream() = default; + InputStream (InputStream const&) = delete; + InputStream& operator= (InputStream const&) = delete; }; } // beast diff --git a/beast/module/core/streams/OutputStream.h b/beast/module/core/streams/OutputStream.h index eb790a1a66..a3feb87c17 100644 --- a/beast/module/core/streams/OutputStream.h +++ b/beast/module/core/streams/OutputStream.h @@ -40,12 +40,15 @@ class File; @see InputStream, MemoryOutputStream, FileOutputStream */ -class OutputStream : public Uncopyable +class OutputStream { protected: //============================================================================== OutputStream(); + OutputStream (OutputStream const&) = delete; + OutputStream& operator= (OutputStream const&) = delete; + public: /** Destructor. diff --git a/beast/module/core/system/SystemStats.h b/beast/module/core/system/SystemStats.h index 3673f1d28b..75eb2258b8 100644 --- a/beast/module/core/system/SystemStats.h +++ b/beast/module/core/system/SystemStats.h @@ -31,7 +31,7 @@ namespace beast /** Contains methods for finding out about the current hardware and OS configuration. */ -class SystemStats : public Uncopyable +class SystemStats { public: //============================================================================== @@ -177,7 +177,9 @@ public: private: //============================================================================== - SystemStats(); + SystemStats() = delete; + SystemStats (SystemStats const&) = delete; + SystemStats const& operator= (SystemStats const&) = delete; }; } // beast diff --git a/beast/module/core/thread/DeadlineTimer.h b/beast/module/core/thread/DeadlineTimer.h index 0cc96f208d..bdefef54cd 100644 --- a/beast/module/core/thread/DeadlineTimer.h +++ b/beast/module/core/thread/DeadlineTimer.h @@ -28,7 +28,6 @@ namespace beast { */ class DeadlineTimer : public List ::Node - , public Uncopyable { public: /** Listener for a deadline timer. @@ -50,6 +49,9 @@ public: */ explicit DeadlineTimer (Listener* listener); + DeadlineTimer (DeadlineTimer const&) = delete; + DeadlineTimer& operator= (DeadlineTimer const&) = delete; + ~DeadlineTimer (); /** Cancel all notifications. diff --git a/beast/module/core/thread/detail/ScopedLock.h b/beast/module/core/thread/detail/ScopedLock.h index d5313f2008..a55d897730 100644 --- a/beast/module/core/thread/detail/ScopedLock.h +++ b/beast/module/core/thread/detail/ScopedLock.h @@ -29,7 +29,7 @@ namespace detail { template -class TrackedScopedLock : public Uncopyable +class TrackedScopedLock { public: inline explicit TrackedScopedLock (Mutex const& mutex, @@ -40,6 +40,9 @@ public: lock (fileName, lineNumber); } + TrackedScopedLock (TrackedScopedLock const&) = delete; + TrackedScopedLock& operator= (TrackedScopedLock const&) = delete; + inline ~TrackedScopedLock () noexcept { if (m_lock_count > 0) @@ -66,7 +69,7 @@ private: //-------------------------------------------------------------------------- template -class TrackedScopedTryLock : public Uncopyable +class TrackedScopedTryLock { public: inline explicit TrackedScopedTryLock (Mutex const& mutex, @@ -77,6 +80,9 @@ public: try_lock (fileName, lineNumber); } + TrackedScopedTryLock (TrackedScopedTryLock const&) = delete; + TrackedScopedTryLock& operator= (TrackedScopedTryLock const&) = delete; + inline ~TrackedScopedTryLock () noexcept { if (m_lock_count > 0) @@ -110,7 +116,7 @@ private: //-------------------------------------------------------------------------- template -class TrackedScopedUnlock : public Uncopyable +class TrackedScopedUnlock { public: inline explicit TrackedScopedUnlock (Mutex const& mutex, @@ -122,6 +128,9 @@ public: m_mutex.unlock (); } + TrackedScopedUnlock (TrackedScopedUnlock const&) = delete; + TrackedScopedUnlock& operator= (TrackedScopedUnlock const&) = delete; + inline ~TrackedScopedUnlock () noexcept { m_mutex.lock (m_fileName, m_lineNumber); @@ -136,7 +145,7 @@ private: //-------------------------------------------------------------------------- template -class UntrackedScopedLock : public Uncopyable +class UntrackedScopedLock { public: inline explicit UntrackedScopedLock (Mutex const& mutex, @@ -147,6 +156,9 @@ public: lock (); } + UntrackedScopedLock (UntrackedScopedLock const&) = delete; + UntrackedScopedLock& operator= (UntrackedScopedLock const&) = delete; + inline ~UntrackedScopedLock () noexcept { if (m_lock_count > 0) @@ -178,7 +190,7 @@ private: //-------------------------------------------------------------------------- template -class UntrackedScopedTryLock : public Uncopyable +class UntrackedScopedTryLock { public: inline explicit UntrackedScopedTryLock (Mutex const& mutex, @@ -189,6 +201,9 @@ public: try_lock (); } + UntrackedScopedTryLock (UntrackedScopedTryLock const&) = delete; + UntrackedScopedTryLock& operator= (UntrackedScopedTryLock const&) = delete; + inline ~UntrackedScopedTryLock () noexcept { if (m_lock_count > 0) @@ -227,7 +242,7 @@ private: //-------------------------------------------------------------------------- template -class UntrackedScopedUnlock : public Uncopyable +class UntrackedScopedUnlock { public: UntrackedScopedUnlock (Mutex const& mutex, @@ -239,6 +254,9 @@ public: m_owns_lock = false; } + UntrackedScopedUnlock (UntrackedScopedUnlock const&) = delete; + UntrackedScopedUnlock& operator= (UntrackedScopedUnlock const&) = delete; + ~UntrackedScopedUnlock () noexcept { MutexTraits ::lock (m_mutex); diff --git a/beast/module/core/threads/CriticalSection.h b/beast/module/core/threads/CriticalSection.h index 5130c568f8..48f1c8c24d 100644 --- a/beast/module/core/threads/CriticalSection.h +++ b/beast/module/core/threads/CriticalSection.h @@ -39,13 +39,16 @@ namespace beast { @see ScopedLock, ScopedTryLock, ScopedUnlock, SpinLock, Thread */ -class CriticalSection : public Uncopyable +class CriticalSection { public: //============================================================================== /** Creates a CriticalSection object. */ CriticalSection() noexcept; + CriticalSection (CriticalSection const&) = delete; + CriticalSection& operator= (CriticalSection const&) = delete; + /** Destructor. If the critical section is deleted whilst locked, any subsequent behaviour is unpredictable. @@ -138,11 +141,13 @@ private: @see CriticalSection, Array, SharedObjectArray */ -class DummyCriticalSection : public Uncopyable +class DummyCriticalSection { public: - inline DummyCriticalSection() noexcept {} - inline ~DummyCriticalSection() noexcept {} + DummyCriticalSection() = default; + DummyCriticalSection (DummyCriticalSection const&) = delete; + DummyCriticalSection& operator= (DummyCriticalSection const&) = delete; + ~DummyCriticalSection() = default; inline void enter() const noexcept {} inline bool tryEnter() const noexcept { return true; } diff --git a/beast/module/core/threads/DynamicLibrary.h b/beast/module/core/threads/DynamicLibrary.h index df8fbc180f..04110cb148 100644 --- a/beast/module/core/threads/DynamicLibrary.h +++ b/beast/module/core/threads/DynamicLibrary.h @@ -34,7 +34,7 @@ namespace beast Since the DLL is freed when this object is deleted, it's handy for managing library lifetimes using RAII. */ -class DynamicLibrary : LeakChecked , public Uncopyable +class DynamicLibrary : LeakChecked { public: /** Creates an unopened DynamicLibrary object. @@ -46,6 +46,9 @@ public: */ DynamicLibrary (const String& name) : handle (nullptr) { open (name); } + DynamicLibrary (DynamicLibrary const&) = delete; + DynamicLibrary& operator= (DynamicLibrary const&) = delete; + /** Destructor. If a library is currently open, it will be closed when this object is destroyed. */ diff --git a/beast/module/core/threads/Process.h b/beast/module/core/threads/Process.h index a9826c7afa..c884d32514 100644 --- a/beast/module/core/threads/Process.h +++ b/beast/module/core/threads/Process.h @@ -34,7 +34,7 @@ namespace beast { @see Thread, BEASTApplication */ -class Process : public Uncopyable +class Process { public: //============================================================================== @@ -130,7 +130,9 @@ public: #endif private: - Process(); + Process() = delete; + Process (Process const&) = delete; + Process const& operator= (Process const&) = delete; }; } // beast diff --git a/beast/module/core/threads/ScopedLock.h b/beast/module/core/threads/ScopedLock.h index 18d7275a0f..16f37ac0cb 100644 --- a/beast/module/core/threads/ScopedLock.h +++ b/beast/module/core/threads/ScopedLock.h @@ -53,7 +53,7 @@ namespace beast @see GenericScopedUnlock, CriticalSection, SpinLock, ScopedLock, ScopedUnlock */ template -class GenericScopedLock : public Uncopyable +class GenericScopedLock { public: //============================================================================== @@ -72,6 +72,9 @@ public: lock.enter(); } + GenericScopedLock (GenericScopedLock const&) = delete; + GenericScopedLock& operator= (GenericScopedLock const&) = delete; + /** Destructor. The lock will be released when the destructor is called. Make sure this object is created and deleted by the same thread, otherwise there are @@ -126,7 +129,7 @@ private: @see GenericScopedLock, CriticalSection, ScopedLock, ScopedUnlock */ template -class GenericScopedUnlock : public Uncopyable +class GenericScopedUnlock { public: //============================================================================== @@ -146,6 +149,9 @@ public: lock.unlock(); } + GenericScopedUnlock (GenericScopedUnlock const&) = delete; + GenericScopedUnlock& operator= (GenericScopedUnlock const&) = delete; + /** Destructor. The CriticalSection will be unlocked when the destructor is called. @@ -200,7 +206,7 @@ private: @see CriticalSection::tryEnter, GenericScopedLock, GenericScopedUnlock */ template -class GenericScopedTryLock : public Uncopyable +class GenericScopedTryLock { public: //============================================================================== @@ -217,6 +223,9 @@ public: inline explicit GenericScopedTryLock (const LockType& lock) noexcept : lock_ (lock), lockWasSuccessful (lock.tryEnter()) {} + GenericScopedTryLock (GenericScopedTryLock const&) = delete; + GenericScopedTryLock& operator= (GenericScopedTryLock const&) = delete; + /** Destructor. The mutex will be unlocked (if it had been successfully locked) when the diff --git a/beast/module/sqdb/detail/ref_counted_statement.h b/beast/module/sqdb/detail/ref_counted_statement.h index 682fda1e36..df3679b0f2 100644 --- a/beast/module/sqdb/detail/ref_counted_statement.h +++ b/beast/module/sqdb/detail/ref_counted_statement.h @@ -65,7 +65,7 @@ namespace sqdb { namespace detail { // used for "once" and "prepare" -class ref_counted_statement_base : public Uncopyable +class ref_counted_statement_base { public: ref_counted_statement_base(session& s); @@ -82,6 +82,11 @@ public: } public: + ref_counted_statement_base ( + ref_counted_statement_base const&) = delete; + ref_counted_statement_base& operator= ( + ref_counted_statement_base const&) = delete; + // break circular header dependency std::ostringstream& get_query_stream(); diff --git a/beast/module/sqdb/detail/type_conversion.h b/beast/module/sqdb/detail/type_conversion.h index 631975fa41..5fc4cc928c 100644 --- a/beast/module/sqdb/detail/type_conversion.h +++ b/beast/module/sqdb/detail/type_conversion.h @@ -76,7 +76,6 @@ template class conversion_into_type : private base_value_holder , public into_type ::base_type> - , public Uncopyable { public: typedef typename type_conversion::base_type BASE_TYPE; @@ -89,6 +88,9 @@ public: : into_type(detail::base_value_holder::m_value, ind) , m_value(value), m_ind(ind) {} + conversion_into_type (conversion_into_type const&) = delete; + conversion_into_type& operator= (conversion_into_type const&) = delete; + private: void convert_from_base() { @@ -107,7 +109,6 @@ template class conversion_use_type : private base_value_holder , public use_type::base_type> - , public Uncopyable { public: typedef typename type_conversion::base_type BASE_TYPE; @@ -128,6 +129,9 @@ public: : use_type(detail::base_value_holder::m_value, ind) , m_value(const_cast(value)), m_ind(ind), m_bReadOnly(true) {} + conversion_use_type (conversion_use_type const&) = delete; + conversion_use_type& operator= (conversion_use_type const&) = delete; + void convert_from_base() { if (!m_bReadOnly) diff --git a/beast/smart_ptr/SharedObject.h b/beast/smart_ptr/SharedObject.h index 12f21b213b..5c0e5efbe1 100644 --- a/beast/smart_ptr/SharedObject.h +++ b/beast/smart_ptr/SharedObject.h @@ -27,7 +27,6 @@ #include #include -#include namespace beast { @@ -63,7 +62,7 @@ namespace beast { @see SharedPtr, SharedObjectArray, SingleThreadedSharedObject */ -class SharedObject : public Uncopyable +class SharedObject { public: //============================================================================== @@ -99,6 +98,9 @@ protected: { } + SharedObject (SharedObject const&) = delete; + SharedObject& operator= (SharedObject const&) = delete; + /** Destructor. */ virtual ~SharedObject() { diff --git a/beast/threads/SharedData.h b/beast/threads/SharedData.h index 707b98de2d..d58976a5b5 100644 --- a/beast/threads/SharedData.h +++ b/beast/threads/SharedData.h @@ -110,7 +110,7 @@ namespace beast { */ template > -class SharedData : public Uncopyable +class SharedData { private: typedef typename SharedMutexType::LockGuardType LockGuardType; @@ -131,7 +131,7 @@ public: generated. */ /** @{ */ - SharedData () { } + SharedData () = default; template explicit SharedData (T1 t1) @@ -165,6 +165,9 @@ public: : m_value (t1, t2, t3, t4, t5, t6, t7, t8) { } /** @} */ + SharedData (SharedData const&) = delete; + SharedData& operator= (SharedData const&) = delete; + private: Value m_value; SharedMutexType m_mutex; @@ -176,7 +179,7 @@ private: This acquires a unique lock on the underlying mutex. */ template -class SharedData ::Access : public Uncopyable +class SharedData ::Access { public: explicit Access (SharedData& state) @@ -184,6 +187,9 @@ public: , m_lock (m_state.m_mutex) { } + Access (Access const&) = delete; + Access& operator= (Access const&) = delete; + Data const& get () const { return m_state.m_value; } Data const& operator* () const { return get (); } Data const* operator-> () const { return &get (); } @@ -202,7 +208,7 @@ private: This acquires a shared lock on the underlying mutex. */ template -class SharedData ::ConstAccess : public Uncopyable +class SharedData ::ConstAccess { public: /** Create a ConstAccess from the specified SharedData */ @@ -211,6 +217,9 @@ public: , m_lock (m_state.m_mutex) { } + ConstAccess (ConstAccess const&) = delete; + ConstAccess& operator= (ConstAccess const&) = delete; + Data const& get () const { return m_state.m_value; } Data const& operator* () const { return get (); } Data const* operator-> () const { return &get (); } @@ -226,7 +235,7 @@ private: This acquires a shared lock on the underlying mutex. */ template -class SharedData ::ConstUnlockedAccess : public Uncopyable +class SharedData ::ConstUnlockedAccess { public: /** Create an UnlockedAccess from the specified SharedData */ @@ -234,6 +243,9 @@ public: : m_state (const_cast (state)) { } + ConstUnlockedAccess (ConstUnlockedAccess const&) = delete; + ConstUnlockedAccess& operator= (ConstUnlockedAccess const&) = delete; + Data const& get () const { return m_state.m_value; } Data const& operator* () const { return get (); } Data const* operator-> () const { return &get (); } @@ -248,7 +260,7 @@ private: This acquires a shared lock on the underlying mutex. */ template -class SharedData ::UnlockedAccess : public Uncopyable +class SharedData ::UnlockedAccess { public: /** Create an UnlockedAccess from the specified SharedData */ @@ -256,6 +268,9 @@ public: : m_state (state) { } + UnlockedAccess (UnlockedAccess const&) = delete; + UnlockedAccess& operator= (UnlockedAccess const&) = delete; + Data const& get () const { return m_state.m_value; } Data const& operator* () const { return get (); } Data const* operator-> () const { return &get (); } diff --git a/beast/threads/SharedLockGuard.h b/beast/threads/SharedLockGuard.h index da9f6b7581..4d2a964d2e 100644 --- a/beast/threads/SharedLockGuard.h +++ b/beast/threads/SharedLockGuard.h @@ -20,14 +20,12 @@ #ifndef BEAST_THREADS_SHAREDLOCKGUARD_H_INCLUDED #define BEAST_THREADS_SHAREDLOCKGUARD_H_INCLUDED -#include - namespace beast { /** A scoped container that acquires a shared lock. */ template -class SharedLockGuard : public Uncopyable +class SharedLockGuard { public: typedef Mutex MutexType; @@ -38,6 +36,9 @@ public: m_mutex.lock_shared(); } + SharedLockGuard (SharedLockGuard const&) = delete; + SharedLockGuard& operator= (SharedLockGuard const&) = delete; + ~SharedLockGuard () { m_mutex.unlock_shared(); diff --git a/beast/threads/SpinLock.h b/beast/threads/SpinLock.h index 717ec2ce45..60434752ed 100644 --- a/beast/threads/SpinLock.h +++ b/beast/threads/SpinLock.h @@ -44,7 +44,7 @@ namespace beast { @see CriticalSection */ -class SpinLock : public Uncopyable +class SpinLock { public: /** Provides the type of scoped lock to use for locking a SpinLock. */ @@ -53,8 +53,10 @@ public: /** Provides the type of scoped unlocker to use with a SpinLock. */ typedef UnlockGuard ScopedUnlockType; - inline SpinLock() noexcept {} - inline ~SpinLock() noexcept {} + SpinLock() = default; + SpinLock (SpinLock const&) = delete; + SpinLock& operator= (SpinLock const&) = delete; + ~SpinLock() = default; /** Acquires the lock. This will block until the lock has been successfully acquired by this thread. diff --git a/beast/threads/Thread.h b/beast/threads/Thread.h index 92443943d2..170828c17f 100644 --- a/beast/threads/Thread.h +++ b/beast/threads/Thread.h @@ -45,7 +45,7 @@ namespace beast { @see CriticalSection, WaitableEvent, Process, ThreadWithProgressWindow, MessageManagerLock */ -class Thread : LeakChecked , public Uncopyable +class Thread : LeakChecked { public: //============================================================================== @@ -57,6 +57,9 @@ public: */ explicit Thread (const String& threadName); + Thread (Thread const&) = delete; + Thread& operator= (Thread const&) = delete; + /** Destructor. If the thread has not been stopped first, this will generate a fatal error. diff --git a/beast/threads/ThreadLocalValue.h b/beast/threads/ThreadLocalValue.h index 99bb024e4c..58b213431d 100644 --- a/beast/threads/ThreadLocalValue.h +++ b/beast/threads/ThreadLocalValue.h @@ -57,13 +57,13 @@ namespace beast { is deleted. */ template -class ThreadLocalValue : public Uncopyable +class ThreadLocalValue { public: /** */ - ThreadLocalValue() noexcept - { - } + ThreadLocalValue() = default; + ThreadLocalValue (ThreadLocalValue const&) = delete; + ThreadLocalValue& operator= (ThreadLocalValue const&) = delete; /** Destructor. When this object is deleted, all the value objects for all threads will be deleted. @@ -176,11 +176,13 @@ public: private: //============================================================================== #if BEAST_NO_COMPILER_THREAD_LOCAL - struct ObjectHolder : public Uncopyable + struct ObjectHolder { ObjectHolder (const Thread::ThreadID& tid) : threadId (tid), object() {} + ObjectHolder (ObjectHolder const&) = delete; + ObjectHolder& operator= (ObjectHolder const&) = delete; Thread::ThreadID threadId; ObjectHolder* next; diff --git a/beast/threads/TryLockGuard.h b/beast/threads/TryLockGuard.h index 55afdae3f5..4b70e9b2b9 100644 --- a/beast/threads/TryLockGuard.h +++ b/beast/threads/TryLockGuard.h @@ -20,12 +20,10 @@ #ifndef BEAST_THREADS_TRYLOCKGUARD_H_INCLUDED #define BEAST_THREADS_TRYLOCKGUARD_H_INCLUDED -#include - namespace beast { template -class TryLockGuard : public Uncopyable +class TryLockGuard { public: typedef Mutex MutexType; @@ -42,6 +40,9 @@ public: m_mutex.unlock(); } + TryLockGuard (TryLockGuard const&) = delete; + TryLockGuard& operator= (TryLockGuard const&) = delete; + bool owns_lock() const { return m_owns_lock; } diff --git a/beast/threads/UnlockGuard.h b/beast/threads/UnlockGuard.h index d8f7b590c8..be87fef263 100644 --- a/beast/threads/UnlockGuard.h +++ b/beast/threads/UnlockGuard.h @@ -20,12 +20,10 @@ #ifndef BEAST_THREADS_UNLOCKGUARD_H_INCLUDED #define BEAST_THREADS_UNLOCKGUARD_H_INCLUDED -#include - namespace beast { template -class UnlockGuard : public Uncopyable +class UnlockGuard { public: typedef Mutex MutexType; @@ -41,6 +39,9 @@ public: m_mutex.lock(); } + UnlockGuard (UnlockGuard const&) = delete; + UnlockGuard& operator= (UnlockGuard const&) = delete; + private: Mutex const& m_mutex; }; diff --git a/beast/threads/WaitableEvent.h b/beast/threads/WaitableEvent.h index b78289a0b0..3a3bd061e9 100644 --- a/beast/threads/WaitableEvent.h +++ b/beast/threads/WaitableEvent.h @@ -25,7 +25,6 @@ #define BEAST_THREADS_WAITABLEEVENT_H_INCLUDED #include -#include #if ! BEAST_WINDOWS #include @@ -39,7 +38,6 @@ namespace beast { method. */ class WaitableEvent - : public Uncopyable //, LeakChecked // VFALCO TODO Move LeakChecked to beast/ { public: @@ -62,6 +60,9 @@ public: */ ~WaitableEvent(); + WaitableEvent (WaitableEvent const&) = delete; + WaitableEvent& operator= (WaitableEvent const&) = delete; + //============================================================================== /** Suspends the calling thread until the event has been signalled. diff --git a/beast/utility/PropertyStream.h b/beast/utility/PropertyStream.h index f42dcf8e2c..d9ce7ad441 100644 --- a/beast/utility/PropertyStream.h +++ b/beast/utility/PropertyStream.h @@ -20,7 +20,6 @@ #ifndef BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED #define BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED -#include #include #include @@ -183,7 +182,7 @@ public: // //------------------------------------------------------------------------------ -class PropertyStream::Map : public Uncopyable +class PropertyStream::Map { private: PropertyStream& m_stream; @@ -195,6 +194,9 @@ public: Map (std::string const& key, PropertyStream& stream); ~Map (); + Map(Map const&) = delete; + Map& operator= (Map const&) = delete; + PropertyStream& stream(); PropertyStream const& stream() const; @@ -241,17 +243,19 @@ PropertyStream::Proxy& PropertyStream::Proxy::operator= (Value value) // //------------------------------------------------------------------------------ -class PropertyStream::Set : public Uncopyable +class PropertyStream::Set { private: PropertyStream& m_stream; public: - explicit Set (Set& set); Set (std::string const& key, Map& map); Set (std::string const& key, PropertyStream& stream); ~Set (); + Set (Set const&) = delete; + Set& operator= (Set const&) = delete; + PropertyStream& stream(); PropertyStream const& stream() const; @@ -267,7 +271,7 @@ public: //------------------------------------------------------------------------------ /** Subclasses can be called to write to a stream and have children. */ -class PropertyStream::Source : public Uncopyable +class PropertyStream::Source { private: struct State @@ -300,6 +304,9 @@ public: explicit Source (std::string const& name); ~Source (); + Source (Source const&) = delete; + Source& operator= (Source const&) = delete; + /** Returns the name of this source. */ std::string const& name() const; diff --git a/beast/utility/StaticObject.h b/beast/utility/StaticObject.h index 15fae2d255..14d36f10d2 100644 --- a/beast/utility/StaticObject.h +++ b/beast/utility/StaticObject.h @@ -90,7 +90,7 @@ private: // This structure gets zero-filled at static initialization time. // No constructors are called. // - class StaticData : public Uncopyable + class StaticData { public: Atomic state; @@ -102,9 +102,10 @@ private: return *(reinterpret_cast (&storage [0])); } - private: - StaticData(); - ~StaticData(); + StaticData() = delete; + StaticData(StaticData const&) = delete; + StaticData& operator= (StaticData const&) = delete; + ~StaticData() = delete; }; }; diff --git a/beast/utility/ci_char_traits.h b/beast/utility/ci_char_traits.h index 3b34932245..1b07152023 100644 --- a/beast/utility/ci_char_traits.h +++ b/beast/utility/ci_char_traits.h @@ -21,6 +21,7 @@ #define BEAST_UTILITY_CI_CHAR_TRAITS_H_INCLUDED #include // +#include #include #include diff --git a/beast/utility/impl/PropertyStream.cpp b/beast/utility/impl/PropertyStream.cpp index a0c3ec190c..bfbd028846 100644 --- a/beast/utility/impl/PropertyStream.cpp +++ b/beast/utility/impl/PropertyStream.cpp @@ -138,12 +138,6 @@ PropertyStream::Proxy PropertyStream::Map::operator[] (std::string const& key) // //------------------------------------------------------------------------------ -PropertyStream::Set::Set (Set& set) - : m_stream (set.m_stream) -{ - m_stream.array_begin (); -} - PropertyStream::Set::Set (std::string const& key, Map& map) : m_stream (map.stream()) {