bufferlist's denc traits claims to be need_contiguous=false, so
it should implement all all functions to work with
buffer::list::const_iterator. we already have decode(), the missing
puzzle is decode_nohead().
in this change, decode_nohead(size_t len, bufferlist& v,
buffer::list::const_iterator& p) is implemented.
same applies to basic_string.
ideally, we should allow decode buffer::list::iterator as well. but
let's leave it for another change in future when it's needed.
Signed-off-by: Kefu Chai <kchai@redhat.com>
s.append(p.get_pos_add(len), len);
}
}
- template<class It>
- static std::enable_if_t<is_const_iterator_v<It>>
- decode_nohead(size_t len, value_type& s, It& p) {
+ static void decode_nohead(size_t len, value_type& s,
+ buffer::list::const_iterator& p) {
if (len) {
if constexpr (std::is_same_v<value_type, std::string>) {
s.clear();
p.copy(len, s);
} else {
- s.resize(len, 0);
+ s.resize(len);
p.copy(len, s.data());
}
} else {
v.append(p.get_ptr(len));
}
}
+ static void decode_nohead(size_t len, bufferlist& v,
+ buffer::list::const_iterator& p) {
+ v.clear();
+ p.copy(len, v);
+ }
};
//