Browse Source

Added a private constructor to Value that should prevent accidentally creating one from an int=0

tags/2021-05-28
jules 11 years ago
parent
commit
edfb1e9830
2 changed files with 5 additions and 7 deletions
  1. +0
    -6
      modules/juce_data_structures/values/juce_Value.cpp
  2. +5
    -1
      modules/juce_data_structures/values/juce_Value.h

+ 0
- 6
modules/juce_data_structures/values/juce_Value.cpp View File

@@ -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 #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
Value::Value (Value&& other) noexcept Value::Value (Value&& other) noexcept
{ {


+ 5
- 1
modules/juce_data_structures/values/juce_Value.h View File

@@ -221,7 +221,11 @@ private:
// This is disallowed to avoid confusion about whether it should // This is disallowed to avoid confusion about whether it should
// do a by-value or by-reference copy. // 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. */ /** Writes a Value to an OutputStream as a UTF8 string. */


Loading…
Cancel
Save