Commit b8012876 by Théo DELRIEU

add noexcept checks, and some missing noexcepts

parent 1554baa0
...@@ -843,7 +843,8 @@ struct adl_serializer ...@@ -843,7 +843,8 @@ struct adl_serializer
} }
template <typename Json, typename T> template <typename Json, typename T>
static void to_json(Json& j, T&& val) static void to_json(Json &j, T &&val) noexcept(
noexcept(::nlohmann::to_json(j, std::forward<T>(val))))
{ {
::nlohmann::to_json(j, std::forward<T>(val)); ::nlohmann::to_json(j, std::forward<T>(val));
} }
......
...@@ -29,6 +29,7 @@ add_executable(${JSON_UNITTEST_TARGET_NAME} ...@@ -29,6 +29,7 @@ add_executable(${JSON_UNITTEST_TARGET_NAME}
"src/unit-meta.cpp" "src/unit-meta.cpp"
"src/unit-modifiers.cpp" "src/unit-modifiers.cpp"
"src/unit-msgpack.cpp" "src/unit-msgpack.cpp"
"src/unit-noexcept.cpp"
"src/unit-pointer_access.cpp" "src/unit-pointer_access.cpp"
"src/unit-readme.cpp" "src/unit-readme.cpp"
"src/unit-reference_access.cpp" "src/unit-reference_access.cpp"
......
#include "catch.hpp"
#include "json.hpp"
using nlohmann::json;
enum test
{
};
struct pod {};
struct pod_bis {};
void to_json(json &, pod) noexcept;
void to_json(json &, pod_bis);
static json j;
static_assert(noexcept(json{}), "");
static_assert(noexcept(nlohmann::to_json(j, 2)), "");
static_assert(noexcept(nlohmann::to_json(j, 2.5)), "");
static_assert(noexcept(nlohmann::to_json(j, true)), "");
static_assert(noexcept(nlohmann::to_json(j, test{})), "");
static_assert(noexcept(nlohmann::to_json(j, pod{})), "");
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{})), "");
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