Removed `ss.str().data()` (the type of ss is std::stringstream).
Introduced variable that is const reference of `ss.str()`.
This commit is contained in:
Takatoshi Kondo
2019-08-29 20:22:10 +09:00
parent 3129326432
commit 70f950ac05
22 changed files with 203 additions and 112 deletions

View File

@@ -31,12 +31,13 @@ int main() {
std::size_t offset = 0;
// msgpack array is constructed on z.
msgpack::object obj = msgpack::unpack(z, ss.str().data(), ss.str().size(), offset);
std::string const& ps = ss.str();
msgpack::object obj = msgpack::unpack(z, ps.data(), ps.size(), offset);
std::cout << obj << std::endl;
assert(obj.as<std::vector<int> >() == v);
// msgpack str is constructed on z.
std::string const& str = msgpack::unpack(z, ss.str().data(), ss.str().size(), offset).as<std::string>();
std::string const& str = msgpack::unpack(z, ps.data(), ps.size(), offset).as<std::string>();
std::cout << str << std::endl;
assert(str == s);
}