1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-31 10:24:23 +03:00

🚧 trying nodiscard attribute #1433

This commit is contained in:
Niels Lohmann
2019-01-19 17:32:23 +01:00
parent b9a39b38bf
commit d359fd3a8d
7 changed files with 49 additions and 3 deletions

View File

@ -37,6 +37,15 @@
#define JSON_DEPRECATED
#endif
// allow for portable nodiscard warnings
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
#define JSON_NODISCARD [[nodiscard]]
#elif defined(__has_cpp_attribute) && __has_cpp_attribute(gnu::warn_unused_result)
#define JSON_NODISCARD [[gnu::warn_unused_result]]
#else
#define JSON_NODISCARD
#endif
// allow to disable exceptions
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
#define JSON_THROW(exception) throw exception