Skip to content

Commit

Permalink
Use JSON_HAS_CPP_17 only after it has been defined
Browse files Browse the repository at this point in the history
  • Loading branch information
remedi committed Dec 17, 2019
1 parent 713038f commit 1b846c9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 32 deletions.
8 changes: 0 additions & 8 deletions include/nlohmann/detail/conversions/from_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
#include <utility> // pair, declval
#include <valarray> // valarray

#ifdef JSON_HAS_CPP_17
#if __has_include(<optional>)
#include <optional>
#elif __has_include(<experimental/optional>)
#include <experimental/optional>
#endif
#endif

#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
Expand Down
8 changes: 0 additions & 8 deletions include/nlohmann/detail/conversions/to_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
#include <valarray> // valarray
#include <vector> // vector

#ifdef JSON_HAS_CPP_17
#if __has_include(<optional>)
#include <optional>
#elif __has_include(<experimental/optional>)
#include <experimental/optional>
#endif
#endif

#include <nlohmann/detail/iterators/iteration_proxy.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
Expand Down
8 changes: 8 additions & 0 deletions include/nlohmann/detail/macro_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
#define JSON_HAS_CPP_14
#endif

#ifdef JSON_HAS_CPP_17
#if __has_include(<optional>)
#include <optional>
#elif __has_include(<experimental/optional>)
#include <experimental/optional>
#endif
#endif

// disable float-equal warnings on GCC/clang
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
Expand Down
24 changes: 8 additions & 16 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ SOFTWARE.
#include <utility> // pair, declval
#include <valarray> // valarray

#ifdef JSON_HAS_CPP_17
#if __has_include(<optional>)
#include <optional>
#elif __has_include(<experimental/optional>)
#include <experimental/optional>
#endif
#endif

// #include <nlohmann/detail/exceptions.hpp>


Expand Down Expand Up @@ -1739,6 +1731,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#define JSON_HAS_CPP_14
#endif

#ifdef JSON_HAS_CPP_17
#if __has_include(<optional>)
#include <optional>
#elif __has_include(<experimental/optional>)
#include <experimental/optional>
#endif
#endif

// disable float-equal warnings on GCC/clang
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
Expand Down Expand Up @@ -3295,14 +3295,6 @@ constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::va
#include <valarray> // valarray
#include <vector> // vector

#ifdef JSON_HAS_CPP_17
#if __has_include(<optional>)
#include <optional>
#elif __has_include(<experimental/optional>)
#include <experimental/optional>
#endif
#endif

// #include <nlohmann/detail/iterators/iteration_proxy.hpp>


Expand Down

0 comments on commit 1b846c9

Please sign in to comment.