From aa597ae00f88d3fd78851f397d6577ebf8425751 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 24 Mar 2017 11:45:15 +0800 Subject: [PATCH] include/denc: define value_type to avoid repeating the type Signed-off-by: Kefu Chai --- src/include/denc.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/include/denc.h b/src/include/denc.h index d9350c530c7e8..350178085b89d 100644 --- a/src/include/denc.h +++ b/src/include/denc.h @@ -524,21 +524,24 @@ inline typename std::enable_if struct denc_traits,A>> { +private: + using value_type = std::basic_string,A>; + +public: static constexpr bool supported = true; static constexpr bool featured = false; static constexpr bool bounded = false; - static void bound_encode(const std::basic_string,A>& s, size_t& p, - uint64_t f=0) { + + static void bound_encode(const value_type& s, size_t& p, uint64_t f=0) { p += sizeof(uint32_t) + s.size(); } - static void encode(const std::basic_string,A>& s, + static void encode(const value_type& s, buffer::list::contiguous_appender& p, uint64_t f=0) { ::denc((uint32_t)s.size(), p); memcpy(p.get_pos_add(s.size()), s.data(), s.size()); } - static void decode(std::basic_string,A>& s, + static void decode(value_type& s, buffer::ptr::iterator& p, uint64_t f=0) { uint32_t len; -- 2.39.5