From dbaf473be803cc9986b7d92f5df490e86b5099fb Mon Sep 17 00:00:00 2001 From: Fabien Servant Date: Mon, 17 Apr 2023 14:10:49 +0200 Subject: [PATCH] as with parameters --- include/msgpack/v1/object.hpp | 7 +++++++ include/msgpack/v1/object_fwd.hpp | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/msgpack/v1/object.hpp b/include/msgpack/v1/object.hpp index fda54be9f..4fe1dca9a 100644 --- a/include/msgpack/v1/object.hpp +++ b/include/msgpack/v1/object.hpp @@ -1134,6 +1134,13 @@ inline typename std::enable_if::value, T>::type object::as() return v; } +template +inline typename std::enable_if::value, T>::type object::as(const C & param) const { + T v; + convert(v, param); + return v; +} + #endif // defined(MSGPACK_USE_CPP03) inline object::object() diff --git a/include/msgpack/v1/object_fwd.hpp b/include/msgpack/v1/object_fwd.hpp index 2562b4164..051bb8e59 100644 --- a/include/msgpack/v1/object_fwd.hpp +++ b/include/msgpack/v1/object_fwd.hpp @@ -129,6 +129,9 @@ struct object { template typename std::enable_if::value, T>::type as() const; + template + typename std::enable_if::value, T>::type as(const C & param) const; + #endif // defined(MSGPACK_USE_CPP03) /// Convert the object @@ -145,6 +148,13 @@ struct object { >::type convert(T& v) const; + template + typename msgpack::enable_if< + !msgpack::is_array::value && !msgpack::is_pointer::value, + T& + >::type + convert(T& v, const C& param) const; + template T (&convert(T(&v)[N]) const)[N];