From edfb1e9830d797eca5a1d5f2e1dc0d6fc5420f85 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 25 Nov 2014 16:29:27 +0000 Subject: [PATCH] Added a private constructor to Value that should prevent accidentally creating one from an int=0 --- modules/juce_data_structures/values/juce_Value.cpp | 6 ------ modules/juce_data_structures/values/juce_Value.h | 6 +++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/juce_data_structures/values/juce_Value.cpp b/modules/juce_data_structures/values/juce_Value.cpp index 55b37fe17b..b0bb40507a 100644 --- a/modules/juce_data_structures/values/juce_Value.cpp +++ b/modules/juce_data_structures/values/juce_Value.cpp @@ -111,12 +111,6 @@ Value::Value (const Value& other) : value (other.value) { } -Value& Value::operator= (const Value& other) -{ - value = other.value; - return *this; -} - #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS Value::Value (Value&& other) noexcept { diff --git a/modules/juce_data_structures/values/juce_Value.h b/modules/juce_data_structures/values/juce_Value.h index f8fc631f33..9563bf8885 100644 --- a/modules/juce_data_structures/values/juce_Value.h +++ b/modules/juce_data_structures/values/juce_Value.h @@ -221,7 +221,11 @@ private: // This is disallowed to avoid confusion about whether it should // do a by-value or by-reference copy. - Value& operator= (const Value&); + Value& operator= (const Value&) JUCE_DELETED_FUNCTION; + + // This declaration prevents accidental construction from an integer of 0, + // which is possible in some compilers via an implicit cast to a pointer. + Value (void*) JUCE_DELETED_FUNCTION; }; /** Writes a Value to an OutputStream as a UTF8 string. */