From cae41d87fb4267f14e9e7486ec4ce06053754e1a Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 19 Apr 2012 16:41:54 +1000 Subject: [PATCH] Add json::node equality operators and specialise --- json.cpp.rl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/json.cpp.rl b/json.cpp.rl index 4e1a02ee..39aab065 100644 --- a/json.cpp.rl +++ b/json.cpp.rl @@ -319,12 +319,17 @@ json::node::as_null (void) const // bool -json::node::operator!=(const node &rhs) const +json::node::operator!= (const node &rhs) const { return !(*this == rhs); } -bool json::node::operator==(const char *rhs) const - { return as_string () == rhs; } +bool json::node::operator==(const char *rhs) const { + try { + return as_string () == rhs; + } catch (const json::type_error&) { + return false; + } +} const json::node&