From 15b67799b365a9c35edc24d74bbda040351e3edf Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 5 Oct 2017 19:46:20 -0700 Subject: [PATCH] ircd::json: Add a buffer. --- include/ircd/json.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/ircd/json.h b/include/ircd/json.h index 451848dd6..e18b25dce 100644 --- a/include/ircd/json.h +++ b/include/ircd/json.h @@ -94,6 +94,7 @@ namespace ircd::json template size_t print(char *const &buf, const size_t &max, T&&... t); template size_t print(const mutable_buffer &buf, T&&... t); template std::string string(T&&... t); + template struct buffer; size_t serialized(const string_view &); @@ -113,6 +114,18 @@ namespace ircd using json::operator<<; } +template +struct ircd::json::buffer +:string_view +{ + std::array b; + + template + buffer(T&&... t) + :string_view{stringify(b, std::forward(t)...)} + {} +}; + /// /// Convenience template for const rvalue mutable_buffers or basically /// allowing a bracket initialization of a mutable_buffer in the argument