include/denc: define value_type to avoid repeating the type

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-03-24 11:45:15 +08:00
parent bb8f633f5d
commit aa597ae00f

View File

@ -524,21 +524,24 @@ inline typename std::enable_if<traits::supported &&
//
template<typename A>
struct denc_traits<std::basic_string<char,std::char_traits<char>,A>> {
private:
using value_type = std::basic_string<char,std::char_traits<char>,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<char,
std::char_traits<char>,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<char,std::char_traits<char>,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<char,std::char_traits<char>,A>& s,
static void decode(value_type& s,
buffer::ptr::iterator& p,
uint64_t f=0) {
uint32_t len;