1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

add constraints for variadic json_ref constructors

Fixes #1292
This commit is contained in:
Théo DELRIEU
2018-10-12 10:54:58 +02:00
parent e426219256
commit 11fecc25af
3 changed files with 33 additions and 8 deletions

View File

@ -10591,6 +10591,9 @@ class serializer
#include <initializer_list>
#include <utility>
// #include <nlohmann/detail/meta/type_traits.hpp>
namespace nlohmann
{
namespace detail
@ -10613,10 +10616,12 @@ class json_ref
: owned_value(init), value_ref(&owned_value), is_rvalue(true)
{}
template<class... Args>
json_ref(Args&& ... args)
: owned_value(std::forward<Args>(args)...), value_ref(&owned_value), is_rvalue(true)
{}
template <
class... Args,
enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
json_ref(Args && ... args)
: owned_value(std::forward<Args>(args)...), value_ref(&owned_value),
is_rvalue(true) {}
// class should be movable only
json_ref(json_ref&&) = default;