mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 16:14:05 +01:00
Add safe bool idiom in JsonString
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Misc/SafeBoolIdiom.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
class String {
|
||||
class String : public SafeBoolIdom<String> {
|
||||
public:
|
||||
String() : _data(0), _isStatic(true) {}
|
||||
String(const char* data, bool isStaticData = true)
|
||||
@@ -24,6 +26,11 @@ class String {
|
||||
return _isStatic;
|
||||
}
|
||||
|
||||
// safe bool idiom
|
||||
operator bool_type() const {
|
||||
return _data ? safe_true() : safe_false();
|
||||
}
|
||||
|
||||
friend bool operator==(String lhs, String rhs) {
|
||||
if (lhs._data == rhs._data)
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user