summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/value.h1
-rw-r--r--src/value.cpp21
2 files changed, 22 insertions, 0 deletions
diff --git a/include/value.h b/include/value.h
index 0990e82..ff18d4e 100644
--- a/include/value.h
+++ b/include/value.h
@@ -94,6 +94,7 @@ public:
* @param value
* @return Value
*/
+ Value &operator=(std::nullptr_t value);
Value &operator=(const Value &value);
Value &operator=(int16_t value);
Value &operator=(int32_t value);
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