using maybe_unused attribute only when supported

Making sure the current configuration supports [[maybe_unused]] before trying to compile with it
This commit is contained in:
Chris Mc 2020-04-19 11:21:10 -04:00 committed by GitHub
parent b28c15adea
commit 35e06a95a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,15 @@
#include "json-patch.hpp" #include "json-patch.hpp"
#ifdef __has_cpp_attribute
#if __has_cpp_attribute(maybe_unused)
#define JSV_MAYBE_UNUSED [[maybe_unused]]
#endif
#endif
#ifndef JSV_MAYBE_UNUSED
#define JSV_MAYBE_UNUSED
#endif
namespace nlohmann namespace nlohmann
{ {
@ -59,7 +69,7 @@ void json_patch::validateJsonPatch(json const &patch)
try { try {
// try parse to path // try parse to path
[[maybe_unused]] const auto p = json::json_pointer{op["path"].get<std::string>()}; JSV_MAYBE_UNUSED const auto p = json::json_pointer{op["path"].get<std::string>()};
} catch (json::exception &e) { } catch (json::exception &e) {
throw JsonPatchFormatException{e.what()}; throw JsonPatchFormatException{e.what()};
} }