Use deleted members to prevent copying in Beast (RIPD-268)

This commit is contained in:
Nik Bougalis
2014-09-25 11:13:38 -07:00
committed by Vinnie Falco
parent cd97b5beec
commit 60330da25c
48 changed files with 255 additions and 191 deletions

View File

@@ -25,7 +25,6 @@
#define BEAST_BYTEORDER_H_INCLUDED
#include <beast/Config.h>
#include <beast/Uncopyable.h>
#include <cstdint>
@@ -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;
};
//==============================================================================

View File

@@ -29,7 +29,6 @@
#include <stdexcept>
#include <beast/Memory.h>
#include <beast/Uncopyable.h>
// 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 ElementType, bool throwOnFailure = false>
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.
*/

View File

@@ -27,7 +27,6 @@
#include <cstring>
#include <beast/Config.h>
#include <beast/Uncopyable.h>
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;
};

View File

@@ -1,77 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
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

View File

@@ -21,7 +21,6 @@
#define BEAST_INTRUSIVE_LIST_H_INCLUDED
#include <beast/Config.h>
#include <beast/Uncopyable.h>
#include <iterator>
#include <type_traits>
@@ -265,7 +264,7 @@ private:
@ingroup beast_core intrusive
*/
template <typename T, typename Tag = void>
class List : public Uncopyable
class List
{
public:
typedef typename detail::ListNode <T, Tag> 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.
*/

View File

@@ -21,7 +21,6 @@
#define BEAST_INTRUSIVE_LOCKFREESTACK_H_INCLUDED
#include <beast/Atomic.h>
#include <beast/Uncopyable.h>
#include <iterator>
#include <type_traits>
@@ -142,15 +141,16 @@ bool operator!= (LockFreeStackIterator <Container, LhsIsConst> const& lhs,
omitted, the default tag is used.
*/
template <class Element, class Tag = void>
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
{

View File

@@ -20,7 +20,6 @@
#ifndef BEAST_ASIO_BASICS_SSLCONTEXT_H_INCLUDED
#define BEAST_ASIO_BASICS_SSLCONTEXT_H_INCLUDED
#include <beast/Uncopyable.h>
#include <boost/asio/ssl/context.hpp>
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;
};

View File

@@ -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();

View File

@@ -55,7 +55,7 @@ namespace beast
@endcode
*/
template <class ObjectType>
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
{

View File

@@ -54,7 +54,7 @@ namespace beast
*/
template <typename ValueType>
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;

View File

@@ -42,7 +42,6 @@
// New header-only library modeled more closely according to boost
#include <beast/SmartPtr.h>
#include <beast/StaticAssert.h>
#include <beast/Uncopyable.h>
#include <beast/Atomic.h>
#include <beast/Arithmetic.h>
#include <beast/ByteOrder.h>

View File

@@ -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;
};

View File

@@ -41,7 +41,7 @@ namespace beast {
It can also guess how far it's got using a wildly inaccurate algorithm.
*/
class DirectoryIterator : LeakChecked <DirectoryIterator>, public Uncopyable
class DirectoryIterator : LeakChecked <DirectoryIterator>
{
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 <NativeIterator>, public Uncopyable
class NativeIterator : LeakChecked <NativeIterator>
{
public:
NativeIterator (const File& directory, const String& wildCard);
NativeIterator(NativeIterator const&) = delete;
NativeIterator& operator= (NativeIterator const&) = delete;
~NativeIterator();
bool next (String& filenameFound,

View File

@@ -39,7 +39,7 @@ namespace beast
@see FileInputStream, FileOutputStream
*/
class RandomAccessFile : public Uncopyable, LeakChecked <RandomAccessFile>
class RandomAccessFile : LeakChecked <RandomAccessFile>
{
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.

View File

@@ -65,7 +65,7 @@ namespace beast
@see File, FileOutputStream
*/
class TemporaryFile : LeakChecked <TemporaryFile>, public Uncopyable
class TemporaryFile : LeakChecked <TemporaryFile>
{
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

View File

@@ -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 ()

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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];

View File

@@ -66,13 +66,16 @@ struct NSObjectRetainer
//==============================================================================
template <typename SuperclassType>
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);

View File

@@ -735,7 +735,6 @@ bool File::createLink (const String& description, const File& linkFileToCreate)
//==============================================================================
class DirectoryIterator::NativeIterator::Pimpl
: LeakChecked <DirectoryIterator::NativeIterator::Pimpl>
, 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)

View File

@@ -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)

View File

@@ -36,7 +36,6 @@ namespace beast
class FileInputSource
: public InputSource
, LeakChecked <FileInputSource>
, 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();

View File

@@ -38,7 +38,6 @@ class MemoryBlock;
@see OutputStream, FileInputStream
*/
class InputStream
: public Uncopyable
, LeakChecked <InputStream>
{
public:
@@ -352,7 +351,9 @@ public:
protected:
//==============================================================================
InputStream() noexcept {}
InputStream() = default;
InputStream (InputStream const&) = delete;
InputStream& operator= (InputStream const&) = delete;
};
} // beast

View File

@@ -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.

View File

@@ -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

View File

@@ -28,7 +28,6 @@ namespace beast {
*/
class DeadlineTimer
: public List <DeadlineTimer>::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.

View File

@@ -29,7 +29,7 @@ namespace detail
{
template <typename Mutex>
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 <typename Mutex>
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 <typename Mutex>
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 <typename Mutex>
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 <typename Mutex>
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 <typename Mutex>
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 <Mutex>::lock (m_mutex);

View File

@@ -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; }

View File

@@ -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 <DynamicLibrary>, public Uncopyable
class DynamicLibrary : LeakChecked <DynamicLibrary>
{
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.
*/

View File

@@ -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

View File

@@ -53,7 +53,7 @@ namespace beast
@see GenericScopedUnlock, CriticalSection, SpinLock, ScopedLock, ScopedUnlock
*/
template <class LockType>
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 LockType>
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 LockType>
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

View File

@@ -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();

View File

@@ -76,7 +76,6 @@ template <typename T>
class conversion_into_type
: private base_value_holder<T>
, public into_type <typename type_conversion<T>::base_type>
, public Uncopyable
{
public:
typedef typename type_conversion<T>::base_type BASE_TYPE;
@@ -89,6 +88,9 @@ public:
: into_type<BASE_TYPE>(detail::base_value_holder<T>::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<typename T>
class conversion_use_type
: private base_value_holder<T>
, public use_type<typename type_conversion<T>::base_type>
, public Uncopyable
{
public:
typedef typename type_conversion<T>::base_type BASE_TYPE;
@@ -128,6 +129,9 @@ public:
: use_type<BASE_TYPE>(detail::base_value_holder<T>::m_value, ind)
, m_value(const_cast<T&>(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)

View File

@@ -27,7 +27,6 @@
#include <atomic>
#include <beast/Config.h>
#include <beast/Uncopyable.h>
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()
{

View File

@@ -110,7 +110,7 @@ namespace beast {
*/
template <typename Value, class SharedMutexType =
SharedMutexAdapter <RecursiveMutex> >
class SharedData : public Uncopyable
class SharedData
{
private:
typedef typename SharedMutexType::LockGuardType LockGuardType;
@@ -131,7 +131,7 @@ public:
generated.
*/
/** @{ */
SharedData () { }
SharedData () = default;
template <class T1>
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 Data, class SharedMutexType>
class SharedData <Data, SharedMutexType>::Access : public Uncopyable
class SharedData <Data, SharedMutexType>::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 Data, class SharedMutexType>
class SharedData <Data, SharedMutexType>::ConstAccess : public Uncopyable
class SharedData <Data, SharedMutexType>::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 Data, class SharedMutexType>
class SharedData <Data, SharedMutexType>::ConstUnlockedAccess : public Uncopyable
class SharedData <Data, SharedMutexType>::ConstUnlockedAccess
{
public:
/** Create an UnlockedAccess from the specified SharedData */
@@ -234,6 +243,9 @@ public:
: m_state (const_cast <SharedData const&> (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 Data, class SharedMutexType>
class SharedData <Data, SharedMutexType>::UnlockedAccess : public Uncopyable
class SharedData <Data, SharedMutexType>::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 (); }

View File

@@ -20,14 +20,12 @@
#ifndef BEAST_THREADS_SHAREDLOCKGUARD_H_INCLUDED
#define BEAST_THREADS_SHAREDLOCKGUARD_H_INCLUDED
#include <beast/Uncopyable.h>
namespace beast
{
/** A scoped container that acquires a shared lock. */
template <typename Mutex>
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();

View File

@@ -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 <SpinLock> 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.

View File

@@ -45,7 +45,7 @@ namespace beast {
@see CriticalSection, WaitableEvent, Process, ThreadWithProgressWindow,
MessageManagerLock
*/
class Thread : LeakChecked <Thread>, public Uncopyable
class Thread : LeakChecked <Thread>
{
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.

View File

@@ -57,13 +57,13 @@ namespace beast {
is deleted.
*/
template <typename Type>
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;

View File

@@ -20,12 +20,10 @@
#ifndef BEAST_THREADS_TRYLOCKGUARD_H_INCLUDED
#define BEAST_THREADS_TRYLOCKGUARD_H_INCLUDED
#include <beast/Uncopyable.h>
namespace beast {
template <typename Mutex>
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; }

View File

@@ -20,12 +20,10 @@
#ifndef BEAST_THREADS_UNLOCKGUARD_H_INCLUDED
#define BEAST_THREADS_UNLOCKGUARD_H_INCLUDED
#include <beast/Uncopyable.h>
namespace beast {
template <typename Mutex>
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;
};

View File

@@ -25,7 +25,6 @@
#define BEAST_THREADS_WAITABLEEVENT_H_INCLUDED
#include <beast/Config.h>
#include <beast/Uncopyable.h>
#if ! BEAST_WINDOWS
#include <pthread.h>
@@ -39,7 +38,6 @@ namespace beast {
method.
*/
class WaitableEvent
: public Uncopyable
//, LeakChecked <WaitableEvent> // 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.

View File

@@ -20,7 +20,6 @@
#ifndef BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED
#define BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED
#include <beast/Uncopyable.h>
#include <beast/intrusive/List.h>
#include <beast/threads/SharedData.h>
@@ -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;

View File

@@ -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 <int> state;
@@ -102,9 +102,10 @@ private:
return *(reinterpret_cast <StaticData*> (&storage [0]));
}
private:
StaticData();
~StaticData();
StaticData() = delete;
StaticData(StaticData const&) = delete;
StaticData& operator= (StaticData const&) = delete;
~StaticData() = delete;
};
};

View File

@@ -21,6 +21,7 @@
#define BEAST_UTILITY_CI_CHAR_TRAITS_H_INCLUDED
#include <beast/cxx14/algorithm.h> // <algorithm>
#include <cctype>
#include <locale>
#include <string>

View File

@@ -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())
{