Closed saur0n closed 8 years ago
Certainly I can see operator bool() being confusing/ambiguous.
There is possibility to declare these operators explicit.
There's no operator bool
because there's no obvious meaning for it. Javascript's semantics for truthiness are somewhat subtle (e.g. an empty string evaluates as false, but an empty array evaluates as true) and that's often a source of confusion. Being more explicit with is_null()
, bool_value()
, etc. makes code easier to read and write.
Er, replace "no obvious meaning" with "too many possible meanings" in the above
But what about other operators (operator int()
, operator std::string()
etc)?
Why there are no
operator int()
,operator std::string()
,operator bool()
and others inJson
class?