|
|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
+#include <ArduinoJson/Misc/SafeBoolIdiom.hpp>
|
|
|
#include <ArduinoJson/Namespace.hpp>
|
|
|
#include <ArduinoJson/Polyfills/preprocessor.hpp>
|
|
|
#include <ArduinoJson/Polyfills/static_array.hpp>
|
|
|
@@ -14,11 +15,7 @@
|
|
|
|
|
|
namespace ARDUINOJSON_NAMESPACE {
|
|
|
|
|
|
-class DeserializationError {
|
|
|
- // safe bool idiom
|
|
|
- typedef void (DeserializationError::*bool_type)() const;
|
|
|
- void safeBoolHelper() const {}
|
|
|
-
|
|
|
+class DeserializationError : public SafeBoolIdom<DeserializationError> {
|
|
|
public:
|
|
|
enum Code {
|
|
|
Ok,
|
|
|
@@ -58,7 +55,7 @@ class DeserializationError {
|
|
|
|
|
|
// Behaves like a bool
|
|
|
operator bool_type() const {
|
|
|
- return _code != Ok ? &DeserializationError::safeBoolHelper : 0;
|
|
|
+ return _code != Ok ? safe_true() : safe_false();
|
|
|
}
|
|
|
friend bool operator==(bool value, const DeserializationError& err) {
|
|
|
return static_cast<bool>(err) == value;
|