Skip to content

Commit 3ca3745

Browse files
committed
Added explicit operator bool()
1 parent 45da594 commit 3ca3745

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

include/json/value.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ Json::Value obj_value(Json::objectValue); // {}
385385
/// Return isNull()
386386
bool operator!() const;
387387

388+
/// Return !isNull()
389+
explicit operator bool() const;
390+
388391
/// Remove all object members and array elements.
389392
/// \pre type() is arrayValue, objectValue, or nullValue
390393
/// \post type() is unchanged

src/lib_json/json_value.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,8 @@ bool Value::empty() const {
927927

928928
bool Value::operator!() const { return isNull(); }
929929

930+
Value::operator bool() const { return !isNull(); }
931+
930932
void Value::clear() {
931933
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue ||
932934
type_ == objectValue,

0 commit comments

Comments
 (0)