diff options
author | Martijn Otto <martijn.otto@copernica.com> | 2014-02-13 16:36:13 +0100 |
---|---|---|
committer | Martijn Otto <martijn.otto@copernica.com> | 2014-02-13 16:36:13 +0100 |
commit | 5c23fee5ce58ae66a70f3bd19a1dc2dff7220f13 (patch) | |
tree | 3b9a8a47a91974d95ba3650705999ae744bc47bd | |
parent | 1a557938e18fb3cf60fbfb7471448fff3ea61c03 (diff) |
Added an assignment operator to Value for nullptr
-rw-r--r-- | include/value.h | 1 | ||||
-rw-r--r-- | src/value.cpp | 21 |
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 |