@@ -203,7 +203,7 @@ namespace Json {
203
203
204
204
#if JSON_USE_EXCEPTION
205
205
Exception::Exception (String msg) : msg_(std::move(msg)) {}
206
- Exception::~Exception () JSONCPP_NOEXCEPT {}
206
+ Exception::~Exception () JSONCPP_NOEXCEPT = default ;
207
207
char const * Exception::what () const JSONCPP_NOEXCEPT { return msg_.c_str (); }
208
208
RuntimeError::RuntimeError (String const & msg) : Exception(msg) {}
209
209
LogicError::LogicError (String const & msg) : Exception(msg) {}
@@ -263,7 +263,7 @@ Value::CZString::CZString(CZString&& other)
263
263
Value::CZString::~CZString () {
264
264
if (cstr_ && storage_.policy_ == duplicate) {
265
265
releaseStringValue (const_cast <char *>(cstr_),
266
- storage_.length_ + 1u ); // +1 for null terminating
266
+ storage_.length_ + 1U ); // +1 for null terminating
267
267
// character for sake of
268
268
// completeness but not actually
269
269
// necessary
@@ -494,7 +494,7 @@ int Value::compare(const Value& other) const {
494
494
bool Value::operator <(const Value& other) const {
495
495
int typeDelta = type () - other.type ();
496
496
if (typeDelta)
497
- return typeDelta < 0 ? true : false ;
497
+ return typeDelta < 0 ;
498
498
switch (type ()) {
499
499
case nullValue:
500
500
return false ;
@@ -508,10 +508,7 @@ bool Value::operator<(const Value& other) const {
508
508
return value_.bool_ < other.value_ .bool_ ;
509
509
case stringValue: {
510
510
if ((value_.string_ == nullptr ) || (other.value_ .string_ == nullptr )) {
511
- if (other.value_ .string_ )
512
- return true ;
513
- else
514
- return false ;
511
+ return other.value_ .string_ != nullptr ;
515
512
}
516
513
unsigned this_len;
517
514
unsigned other_len;
@@ -809,7 +806,7 @@ float Value::asFloat() const {
809
806
case nullValue:
810
807
return 0.0 ;
811
808
case booleanValue:
812
- return value_.bool_ ? 1 .0f : 0 .0f ;
809
+ return value_.bool_ ? 1 .0F : 0 .0F ;
813
810
default :
814
811
break ;
815
812
}
@@ -823,9 +820,9 @@ bool Value::asBool() const {
823
820
case nullValue:
824
821
return false ;
825
822
case intValue:
826
- return value_.int_ ? true : false ;
823
+ return value_.int_ != 0 ;
827
824
case uintValue:
828
- return value_.uint_ ? true : false ;
825
+ return value_.uint_ != 0 ;
829
826
case realValue: {
830
827
// According to JavaScript language zero or NaN is regarded as false
831
828
const auto value_classification = std::fpclassify (value_.real_ );
@@ -841,7 +838,7 @@ bool Value::isConvertibleTo(ValueType other) const {
841
838
switch (other) {
842
839
case nullValue:
843
840
return (isNumeric () && asDouble () == 0.0 ) ||
844
- (type () == booleanValue && value_.bool_ == false ) ||
841
+ (type () == booleanValue && ! value_.bool_ ) ||
845
842
(type () == stringValue && asString ().empty ()) ||
846
843
(type () == arrayValue && value_.map_ ->empty ()) ||
847
844
(type () == objectValue && value_.map_ ->empty ()) ||
@@ -896,7 +893,7 @@ ArrayIndex Value::size() const {
896
893
897
894
bool Value::empty () const {
898
895
if (isNull () || isArray () || isObject ())
899
- return size () == 0u ;
896
+ return size () == 0U ;
900
897
else
901
898
return false ;
902
899
}
@@ -1545,15 +1542,14 @@ Value::iterator Value::end() {
1545
1542
// class PathArgument
1546
1543
// //////////////////////////////////////////////////////////////////
1547
1544
1548
- PathArgument::PathArgument () {}
1545
+ PathArgument::PathArgument () = default ;
1549
1546
1550
1547
PathArgument::PathArgument (ArrayIndex index)
1551
1548
: index_(index), kind_(kindIndex) {}
1552
1549
1553
1550
PathArgument::PathArgument (const char * key) : key_(key), kind_(kindKey) {}
1554
1551
1555
- PathArgument::PathArgument (const String& key)
1556
- : key_(key.c_str()), kind_(kindKey) {}
1552
+ PathArgument::PathArgument (String key) : key_(std::move(key)), kind_(kindKey) {}
1557
1553
1558
1554
// class Path
1559
1555
// //////////////////////////////////////////////////////////////////
0 commit comments