From 4611528bb863cda307e19c04179cfb30522c89b1 Mon Sep 17 00:00:00 2001 From: Alexey Ochapov Date: Sat, 6 Feb 2021 12:54:20 +0300 Subject: [PATCH] guard instantiation of detail::detector in conversion operator of basic_json to workaround strange Clang behavior: https://bugs.llvm.org/show_bug.cgi?id=48507 --- include/nlohmann/detail/meta/detected.hpp | 2 +- include/nlohmann/json.hpp | 17 ++++++++++------- single_include/nlohmann/json.hpp | 19 +++++++++++-------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/include/nlohmann/detail/meta/detected.hpp b/include/nlohmann/detail/meta/detected.hpp index 7b5a003537..deea3e17c3 100644 --- a/include/nlohmann/detail/meta/detected.hpp +++ b/include/nlohmann/detail/meta/detected.hpp @@ -37,7 +37,7 @@ struct detector>, Op, Args...> }; template class Op, class... Args> -using is_detected = typename detector::value_t; +struct is_detected : detector::value_t {}; template class Op, class... Args> using detected_t = typename detector::type; diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 0bbaa9503a..1215747ec8 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3342,15 +3342,18 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec @since version 1.0.0 */ template < typename ValueType, typename std::enable_if < - !std::is_pointer::value&& - !std::is_same>::value&& - !std::is_same::value&& - !detail::is_basic_json::value - && !std::is_same>::value + detail::conjunction < + std::integral_constant < bool, + !std::is_pointer::value&& + !std::is_same>::value&& + !std::is_same::value&& + !detail::is_basic_json::value + && !std::is_same>::value #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) - && !std::is_same::value + && !std::is_same::value #endif - && detail::is_detected::value + >, + detail::is_detected>::value , int >::type = 0 > JSON_EXPLICIT operator ValueType() const { diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 2716e1e7b3..2e8dd72b27 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -3305,7 +3305,7 @@ struct detector>, Op, Args...> }; template class Op, class... Args> -using is_detected = typename detector::value_t; +struct is_detected : detector::value_t {}; template class Op, class... Args> using detected_t = typename detector::type; @@ -20362,15 +20362,18 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec @since version 1.0.0 */ template < typename ValueType, typename std::enable_if < - !std::is_pointer::value&& - !std::is_same>::value&& - !std::is_same::value&& - !detail::is_basic_json::value - && !std::is_same>::value + detail::conjunction < + std::integral_constant < bool, + !std::is_pointer::value&& + !std::is_same>::value&& + !std::is_same::value&& + !detail::is_basic_json::value + && !std::is_same>::value #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) - && !std::is_same::value + && !std::is_same::value #endif - && detail::is_detected::value + >, + detail::is_detected>::value , int >::type = 0 > JSON_EXPLICIT operator ValueType() const {