summaryrefslogtreecommitdiff
path: root/src/value.cpp
diff options
context:
space:
mode:
authorMartijn Otto <martijn.otto@copernica.com>2014-02-13 16:36:13 +0100
committerMartijn Otto <martijn.otto@copernica.com>2014-02-13 16:36:13 +0100
commit5c23fee5ce58ae66a70f3bd19a1dc2dff7220f13 (patch)
tree3b9a8a47a91974d95ba3650705999ae744bc47bd /src/value.cpp
parent1a557938e18fb3cf60fbfb7471448fff3ea61c03 (diff)
Added an assignment operator to Value for nullptr
Diffstat (limited to 'src/value.cpp')
-rw-r--r--src/value.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/value.cpp b/src/value.cpp
index 1fec43a..4170404 100644
--- a/src/value.cpp
+++ b/src/value.cpp
@@ -348,6 +348,27 @@ Value &Value::operator=(const Value &value)
return validate();
}
+
+/**
+ * Assignment operator
+ * @param value
+ * @return Value
+ */
+Value &Value::operator=(std::nullptr_t value)
+{
+ // if this is not a reference variable, we should detach it to implement copy on write
+ SEPARATE_ZVAL_IF_NOT_REF(&_val);
+
+ // deallocate current zval (without cleaning the zval structure)
+ zval_dtor(_val);
+
+ // change to null value
+ ZVAL_NULL(_val);
+
+ // update the object
+ return validate();
+}
+
/**
* Assignment operator
* @param value