From fcd3f7370466a5ee995da0551bc90de7a1a7db02 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 15 Aug 2012 16:04:10 +1000 Subject: [PATCH] Add argument forwarding to {to,from}_json --- json.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/json.hpp b/json.hpp index 76b518cf..b86476e9 100644 --- a/json.hpp +++ b/json.hpp @@ -274,6 +274,9 @@ namespace json { operator <<(std::ostream &os, const json::node &n); + // 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 struct io { static std::unique_ptr serialise (const T&); @@ -282,14 +285,14 @@ namespace json { } -template -json::node&& to_json (const T &t) { - return json::io::serialise (t); +template +json::node&& to_json (const T &t, Args&&... args) { + return json::io::serialise (t, std::forward(args)...); } -template -T from_json (const json::node &n) { - return json::io::deserialise (n); +template +T from_json (const json::node &n, Args&&... args) { + return json::io::deserialise (n, std::forward(args)...); } #endif