From 51a3829680dd5f5a67fe5c0390151c3157294639 Mon Sep 17 00:00:00 2001 From: Niels Date: Fri, 22 Jul 2016 15:53:38 +0200 Subject: [PATCH] reverted change to constexpr get_ref (does not work with GCC and MSVC) --- src/json.hpp | 19 +++++++++++++------ src/json.hpp.re2c | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 00bee970..b581fea1 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -2806,16 +2806,23 @@ class basic_json type of the current JSON */ template - static constexpr ReferenceType get_ref_impl(ThisType& obj) + static ReferenceType get_ref_impl(ThisType& obj) { // helper type using PointerType = typename std::add_pointer::type; // delegate the call to get_ptr<>() - return obj.template get_ptr() != nullptr - ? *obj.template get_ptr() - : throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " + - obj.type_name()); + auto ptr = obj.template get_ptr(); + + if (ptr != nullptr) + { + return *ptr; + } + else + { + throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " + + obj.type_name()); + } } public: @@ -3043,7 +3050,7 @@ class basic_json std::is_reference::value and std::is_const::type>::value , int>::type = 0> - constexpr ReferenceType get_ref() const + ReferenceType get_ref() const { // delegate call to get_ref_impl return get_ref_impl(*this); diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 05c49ec5..73185c6b 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -2806,16 +2806,23 @@ class basic_json type of the current JSON */ template - static constexpr ReferenceType get_ref_impl(ThisType& obj) + static ReferenceType get_ref_impl(ThisType& obj) { // helper type using PointerType = typename std::add_pointer::type; // delegate the call to get_ptr<>() - return obj.template get_ptr() != nullptr - ? *obj.template get_ptr() - : throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " + - obj.type_name()); + auto ptr = obj.template get_ptr(); + + if (ptr != nullptr) + { + return *ptr; + } + else + { + throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " + + obj.type_name()); + } } public: @@ -3043,7 +3050,7 @@ class basic_json std::is_reference::value and std::is_const::type>::value , int>::type = 0> - constexpr ReferenceType get_ref() const + ReferenceType get_ref() const { // delegate call to get_ref_impl return get_ref_impl(*this);