json/tree: forward the arguments for to_json/from_json
This commit is contained in:
parent
b918aa7fc0
commit
65dad60e09
@ -350,10 +350,13 @@ namespace json::tree {
|
||||
// Instantiate this template for the type you wish to output. We use a
|
||||
// helper class here to avoid partial template specialisation of a
|
||||
// function (eg, for templated types).
|
||||
template <typename T>
|
||||
template <typename T, typename ...Args>
|
||||
struct io {
|
||||
static std::unique_ptr<json::tree::node> serialise (const T&);
|
||||
static T deserialise (const json::tree::node&);
|
||||
static std::unique_ptr<json::tree::node>
|
||||
serialise (const T&, Args &&...args);
|
||||
|
||||
static T
|
||||
deserialise (const json::tree::node&, Args &&...args);
|
||||
};
|
||||
}
|
||||
|
||||
@ -363,7 +366,7 @@ template <typename T, class ...Args>
|
||||
std::unique_ptr<json::tree::node>
|
||||
to_json (const T &t, Args&&... args)
|
||||
{
|
||||
return json::tree::io<T>::serialise (
|
||||
return json::tree::io<T,Args...>::serialise (
|
||||
t, std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
@ -374,7 +377,7 @@ template <typename T, class ...Args>
|
||||
T
|
||||
from_json (const json::tree::node &n, Args&&... args)
|
||||
{
|
||||
return json::tree::io<T>::deserialise (
|
||||
return json::tree::io<T,Args...>::deserialise (
|
||||
n, std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
@ -385,7 +388,7 @@ template <typename T, class ...Args>
|
||||
T
|
||||
from_json (const std::experimental::filesystem::path &src, Args &&...args)
|
||||
{
|
||||
return from_json<T> (
|
||||
return from_json<T,Args...> (
|
||||
*json::tree::parse (src),
|
||||
std::forward<Args> (args)...
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user