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
No known key found for this signature in database
GPG key ID: A5A505438C20539A
3 changed files with 33 additions and 8 deletions

View file

@ -3,6 +3,8 @@
#include <initializer_list>
#include <utility>
#include <nlohmann/detail/meta/type_traits.hpp>
namespace nlohmann
{
namespace detail
@ -25,10 +27,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;