From b56117b148b346b78a9928764b03326bce96d3df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20DELRIEU?= <theo@tanker.io>
Date: Mon, 16 Jan 2017 21:59:47 +0100
Subject: [PATCH] add noexcept tests

---
 src/json.hpp               | 2 +-
 src/json.hpp.re2c          | 2 +-
 test/src/unit-noexcept.cpp | 5 +++++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/json.hpp b/src/json.hpp
index 838d2d07..9c0a8168 100644
--- a/src/json.hpp
+++ b/src/json.hpp
@@ -840,7 +840,7 @@ template <typename = void, typename = void>
 struct adl_serializer
 {
     template <typename Json, typename T>
-    static void from_json(Json&& j, T& val)
+    static void from_json(Json&& j, T& val) noexcept(noexcept(::nlohmann::from_json(std::forward<Json>(j), val)))
     {
         ::nlohmann::from_json(std::forward<Json>(j), val);
     }
diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c
index a3539180..8fbff2ad 100644
--- a/src/json.hpp.re2c
+++ b/src/json.hpp.re2c
@@ -840,7 +840,7 @@ template <typename = void, typename = void>
 struct adl_serializer
 {
     template <typename Json, typename T>
-    static void from_json(Json&& j, T& val)
+    static void from_json(Json&& j, T& val) noexcept(noexcept(::nlohmann::from_json(std::forward<Json>(j), val)))
     {
         ::nlohmann::from_json(std::forward<Json>(j), val);
     }
diff --git a/test/src/unit-noexcept.cpp b/test/src/unit-noexcept.cpp
index 212abdf7..de13e057 100644
--- a/test/src/unit-noexcept.cpp
+++ b/test/src/unit-noexcept.cpp
@@ -13,6 +13,8 @@ struct pod_bis {};
 
 void to_json(json &, pod) noexcept;
 void to_json(json &, pod_bis);
+void from_json(const json&, pod) noexcept;
+void from_json(const json&, pod_bis);
 static json j;
 
 static_assert(noexcept(json{}), "");
@@ -25,3 +27,6 @@ static_assert(not noexcept(nlohmann::to_json(j, pod_bis{})), "");
 static_assert(noexcept(json(2)), "");
 static_assert(noexcept(json(test{})), "");
 static_assert(noexcept(json(pod{})), "");
+static_assert(noexcept(j.get<pod>()), "");
+static_assert(not noexcept(j.get<pod_bis>()), "");
+static_assert(noexcept(json(pod{})), "");