From 0974400f1a84d37d3fd7399938039b2966b81464 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 20 Apr 2012 18:07:42 +1000 Subject: [PATCH] Make json constructors explicit --- json.cpp.rl | 2 +- json.hpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/json.cpp.rl b/json.cpp.rl index 5f0607e9..5e925cc7 100644 --- a/json.cpp.rl +++ b/json.cpp.rl @@ -344,7 +344,7 @@ json::node::operator!= (const node &rhs) const bool json::node::operator==(const char *rhs) const { try { - return as_string () == rhs; + return as_string ().native () == rhs; } catch (const json::type_error&) { return false; } diff --git a/json.hpp b/json.hpp index 8eecb5ad..effa59f8 100644 --- a/json.hpp +++ b/json.hpp @@ -161,8 +161,8 @@ namespace json { std::string m_value; public: - string (const std::string &_value): m_value (_value) { ; } - string (const char *_value): m_value (_value) { ; } + explicit string (const std::string &_value): m_value (_value) { ; } + explicit string (const char *_value): m_value (_value) { ; } virtual const string& as_string (void) const { return *this; } virtual bool is_string (void) const { return true; } @@ -185,8 +185,8 @@ namespace json { double m_value; public: - number (double _value): m_value (_value) { ; } - number (int _value): m_value (_value) { ; } + explicit number (double _value): m_value (_value) { ; } + explicit number (int _value): m_value (_value) { ; } virtual const number& as_number (void) const { return *this; } virtual bool is_number (void) const { return true; } @@ -207,7 +207,7 @@ namespace json { bool m_value; public: - boolean (bool _value): m_value (_value) { ; } + explicit boolean (bool _value): m_value (_value) { ; } virtual const boolean& as_boolean (void) const { return *this; } virtual bool is_boolean (void) const { return true; }