Commit 51a38296 authored by Niels's avatar Niels

reverted change to constexpr get_ref (does not work with GCC and MSVC)

parent 4e7501e5
...@@ -2806,16 +2806,23 @@ class basic_json ...@@ -2806,16 +2806,23 @@ class basic_json
type of the current JSON type of the current JSON
*/ */
template<typename ReferenceType, typename ThisType> template<typename ReferenceType, typename ThisType>
static constexpr ReferenceType get_ref_impl(ThisType& obj) static ReferenceType get_ref_impl(ThisType& obj)
{ {
// helper type // helper type
using PointerType = typename std::add_pointer<ReferenceType>::type; using PointerType = typename std::add_pointer<ReferenceType>::type;
// delegate the call to get_ptr<>() // delegate the call to get_ptr<>()
return obj.template get_ptr<PointerType>() != nullptr auto ptr = obj.template get_ptr<PointerType>();
? *obj.template get_ptr<PointerType>()
: throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " + if (ptr != nullptr)
obj.type_name()); {
return *ptr;
}
else
{
throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
obj.type_name());
}
} }
public: public:
...@@ -3043,7 +3050,7 @@ class basic_json ...@@ -3043,7 +3050,7 @@ class basic_json
std::is_reference<ReferenceType>::value std::is_reference<ReferenceType>::value
and std::is_const<typename std::remove_reference<ReferenceType>::type>::value and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
, int>::type = 0> , int>::type = 0>
constexpr ReferenceType get_ref() const ReferenceType get_ref() const
{ {
// delegate call to get_ref_impl // delegate call to get_ref_impl
return get_ref_impl<ReferenceType>(*this); return get_ref_impl<ReferenceType>(*this);
......
...@@ -2806,16 +2806,23 @@ class basic_json ...@@ -2806,16 +2806,23 @@ class basic_json
type of the current JSON type of the current JSON
*/ */
template<typename ReferenceType, typename ThisType> template<typename ReferenceType, typename ThisType>
static constexpr ReferenceType get_ref_impl(ThisType& obj) static ReferenceType get_ref_impl(ThisType& obj)
{ {
// helper type // helper type
using PointerType = typename std::add_pointer<ReferenceType>::type; using PointerType = typename std::add_pointer<ReferenceType>::type;
// delegate the call to get_ptr<>() // delegate the call to get_ptr<>()
return obj.template get_ptr<PointerType>() != nullptr auto ptr = obj.template get_ptr<PointerType>();
? *obj.template get_ptr<PointerType>()
: throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " + if (ptr != nullptr)
obj.type_name()); {
return *ptr;
}
else
{
throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
obj.type_name());
}
} }
public: public:
...@@ -3043,7 +3050,7 @@ class basic_json ...@@ -3043,7 +3050,7 @@ class basic_json
std::is_reference<ReferenceType>::value std::is_reference<ReferenceType>::value
and std::is_const<typename std::remove_reference<ReferenceType>::type>::value and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
, int>::type = 0> , int>::type = 0>
constexpr ReferenceType get_ref() const ReferenceType get_ref() const
{ {
// delegate call to get_ref_impl // delegate call to get_ref_impl
return get_ref_impl<ReferenceType>(*this); return get_ref_impl<ReferenceType>(*this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment