diff --git a/src/json.hpp b/src/json.hpp index c40691a5..d238a28f 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -3107,14 +3107,13 @@ class basic_json // do we really want the uncvref ? if a user call get, shouldn't we // static assert ? // i know there is a special behaviour for boolean_t* and such - auto get() const noexcept(noexcept(JSONSerializer::from_json( - std::declval(), std::declval()))) - -> U + U get() const noexcept(noexcept(JSONSerializer::from_json( + std::declval(), std::declval()))) { static_assert(std::is_default_constructible::value and - std::is_copy_constructible::value, - "Types must be DefaultConstructible and " - "CopyConstructible when used with get"); + std::is_copy_constructible::value, + "Types must be DefaultConstructible and " + "CopyConstructible when used with get"); U ret; JSONSerializer::from_json(*this, ret); return ret; @@ -3137,11 +3136,12 @@ class basic_json */ template < typename T, - detail::enable_if_t>::value and + typename U = detail::uncvref_t, + detail::enable_if_t::value and detail::has_non_default_from_json>::value, + U>::value, int> = 0 > - detail::uncvref_t get() const noexcept(noexcept(JSONSerializer::from_json(std::declval()))) + U get() const noexcept(noexcept(JSONSerializer::from_json(std::declval()))) { return JSONSerializer::from_json(*this); } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index e3fee848..9510cddc 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -3107,14 +3107,13 @@ class basic_json // do we really want the uncvref ? if a user call get, shouldn't we // static assert ? // i know there is a special behaviour for boolean_t* and such - auto get() const noexcept(noexcept(JSONSerializer::from_json( - std::declval(), std::declval()))) - -> U + U get() const noexcept(noexcept(JSONSerializer::from_json( + std::declval(), std::declval()))) { static_assert(std::is_default_constructible::value and - std::is_copy_constructible::value, - "Types must be DefaultConstructible and " - "CopyConstructible when used with get"); + std::is_copy_constructible::value, + "Types must be DefaultConstructible and " + "CopyConstructible when used with get"); U ret; JSONSerializer::from_json(*this, ret); return ret; @@ -3137,11 +3136,12 @@ class basic_json */ template < typename T, - detail::enable_if_t>::value and + typename U = detail::uncvref_t, + detail::enable_if_t::value and detail::has_non_default_from_json>::value, + U>::value, int> = 0 > - detail::uncvref_t get() const noexcept(noexcept(JSONSerializer::from_json(std::declval()))) + U get() const noexcept(noexcept(JSONSerializer::from_json(std::declval()))) { return JSONSerializer::from_json(*this); }