From 1d87097741520289ae5ab4cc49c8db546ccd9209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20DELRIEU?= Date: Sun, 15 Jan 2017 22:08:33 +0100 Subject: [PATCH] remove some boilerplate --- src/json.hpp | 22 +++++++++++----------- src/json.hpp.re2c | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 8e14b5cd..9d4a548a 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -3019,26 +3019,26 @@ class basic_json // the latter is preferred if both are present (since it does not require a default construction of T) template < typename T, + typename U = uncvref_t, enable_if_t< - not std::is_same>::value and - detail::has_from_json>::value and + not std::is_same::value and + detail::has_from_json::value and not detail::has_non_default_from_json>::value, + U>::value, int> = 0> // 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 &>()))) - -> uncvref_t + auto get() const noexcept(noexcept(JSONSerializer::from_json( + std::declval(), std::declval()))) + -> U { - using type = uncvref_t; - static_assert(std::is_default_constructible::value and - std::is_copy_constructible::value, + static_assert(std::is_default_constructible::value and + std::is_copy_constructible::value, "Types must be DefaultConstructible and " "CopyConstructible when used with get"); - type ret; - JSONSerializer::from_json(*this, ret); + U ret; + JSONSerializer::from_json(*this, ret); return ret; } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index f4d0cf8d..4b28a032 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -3019,26 +3019,26 @@ class basic_json // the latter is preferred if both are present (since it does not require a default construction of T) template < typename T, + typename U = uncvref_t, enable_if_t< - not std::is_same>::value and - detail::has_from_json>::value and + not std::is_same::value and + detail::has_from_json::value and not detail::has_non_default_from_json>::value, + U>::value, int> = 0> // 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 &>()))) - -> uncvref_t + auto get() const noexcept(noexcept(JSONSerializer::from_json( + std::declval(), std::declval()))) + -> U { - using type = uncvref_t; - static_assert(std::is_default_constructible::value and - std::is_copy_constructible::value, + static_assert(std::is_default_constructible::value and + std::is_copy_constructible::value, "Types must be DefaultConstructible and " "CopyConstructible when used with get"); - type ret; - JSONSerializer::from_json(*this, ret); + U ret; + JSONSerializer::from_json(*this, ret); return ret; }