From fcd40105a7d698e8241e8167fec1c61610dec330 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 1 Sep 2014 16:25:24 +1000 Subject: [PATCH] json: serialisation/instantiation from size_t --- json.cpp.rl | 6 ++++++ json.hpp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/json.cpp.rl b/json.cpp.rl index 416697a0..8d05db09 100644 --- a/json.cpp.rl +++ b/json.cpp.rl @@ -586,6 +586,12 @@ namespace json { return std::unique_ptr (new number (i)); } + template <> + std::unique_ptr + io::serialise (const size_t &i) { + return std::unique_ptr (new number (i)); + } + template <> std::unique_ptr io::serialise (const float &f) { diff --git a/json.hpp b/json.hpp index ba59b99a..af4ccd7b 100644 --- a/json.hpp +++ b/json.hpp @@ -189,7 +189,8 @@ namespace json { public: explicit number (double _value): m_value (_value) { ; } - explicit number (int _value): m_value (_value) { ; } + explicit number (int _value): m_value (_value) { ; } + explicit number (size_t _value): m_value (_value) { ; } virtual const number& as_number (void) const { return *this; } virtual bool is_number (void) const { return true; }