Skip to content

Commit

Permalink
🔨 trying code from https://godbolt.org/z/-tLO1K
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Jan 20, 2019
1 parent d359fd3 commit e36593e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions include/nlohmann/detail/macro_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@
#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]]
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(nodiscard)
#define JSON_NODISCARD [[nodiscard]]
#elif __has_cpp_attribute(gnu::warn_unused_result)
#define JSON_NODISCARD [[gnu::warn_unused_result]]
#else
#define JSON_NODISCARD
#endif
#else
#define JSON_NODISCARD
#endif
Expand Down
12 changes: 8 additions & 4 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,14 @@ using json = basic_json<>;
#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]]
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(nodiscard)
#define JSON_NODISCARD [[nodiscard]]
#elif __has_cpp_attribute(gnu::warn_unused_result)
#define JSON_NODISCARD [[gnu::warn_unused_result]]
#else
#define JSON_NODISCARD
#endif
#else
#define JSON_NODISCARD
#endif
Expand Down

0 comments on commit e36593e

Please sign in to comment.