diff --git a/src/json.hpp b/src/json.hpp index 68ac29fc..528c92b2 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -127,6 +127,9 @@ using remove_cv_t = typename std::remove_cv::type; template using remove_reference_t = typename std::remove_reference::type; +template +using uncvref_t = remove_cv_t>; + // TODO update this doc /*! @brief unnamed namespace with internal helper functions @@ -1404,11 +1407,12 @@ class basic_json // auto j = json{{"a", json(not_equality_comparable{})}}; // // we can remove this constraint though, since lots of ctor are not explicit already - template >>::value>> + template >::value>> explicit basic_json(T &&val) - : basic_json(json_traits>>::to_json( - std::forward(val))) {} + : basic_json(json_traits>::to_json(std::forward(val))) + { + } /*! @brief create a string (explicit) @@ -2771,12 +2775,12 @@ class basic_json // get_impl overload chosen if json_traits struct is specialized for type T // simply returns json_traits::from_json(*this); - template >>::value>> - auto get_impl(T *) const - -> decltype(json_traits>>::from_json( - std::declval())) { - return json_traits>>::from_json(*this); + template >::value>> + auto get_impl(T *) const -> decltype( + json_traits>::from_json(std::declval())) + { + return json_traits>::from_json(*this); } // this one is quite atrocious @@ -2784,12 +2788,11 @@ class basic_json // I chose to prefer the json_traits specialization if it exists, since it's a more advanced use. // But we can of course change this behaviour template - auto get_impl(T *) const - -> enable_if_t>::value, - remove_cv_t(), + auto get_impl(T *) const -> enable_if_t< + not detail::has_json_traits>::value, + uncvref_t(), std::declval()), - std::declval())>>> + std::declval())>> { remove_cv_t ret; // I guess this output parameter is the only way to get ADL