From 6eb37e9b7881057b6f6fb646a46fd2c1ea4c79a1 Mon Sep 17 00:00:00 2001 From: Anthony VH Date: Thu, 14 Jan 2021 12:39:03 +0100 Subject: [PATCH] Only add conditional constexpr to get() for >= C++14 to work around errors on older compilers. --- include/nlohmann/json.hpp | 5 ++++- single_include/nlohmann/json.hpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index a7adb724f..e5a7917c5 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3063,7 +3063,10 @@ class basic_json @since version 2.1.0 */ template < typename ValueTypeCV, typename ValueType = detail::uncvref_t> - constexpr auto get() const noexcept( +#if defined(JSON_HAS_CPP_14) + constexpr +#endif + auto get() const noexcept( noexcept(std::declval().template get_impl(detail::priority_tag<4> {}))) -> decltype(std::declval().template get_impl(detail::priority_tag<4> {})) { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index f7ee9030b..7ce313829 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -19815,7 +19815,10 @@ class basic_json @since version 2.1.0 */ template < typename ValueTypeCV, typename ValueType = detail::uncvref_t> - constexpr auto get() const noexcept( +#if defined(JSON_HAS_CPP_14) + constexpr +#endif + auto get() const noexcept( noexcept(std::declval().template get_impl(detail::priority_tag<4> {}))) -> decltype(std::declval().template get_impl(detail::priority_tag<4> {})) {