Fixed a compile error on clang++ 3.4.1 on FreeBSD and Yosemite.

This commit is contained in:
Takatoshi Kondo 2015-03-10 18:37:36 +09:00
parent c3518c0666
commit 118cf7270c
2 changed files with 36 additions and 0 deletions

View File

@ -42,6 +42,37 @@ inline object const& operator>> (object const& o, std::vector<bool>& v)
return o;
}
template <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const std::vector<bool>& v)
{
o.pack_array(v.size());
for(std::vector<bool>::const_iterator it(v.begin()), it_end(v.end());
it != it_end; ++it) {
o.pack(*it);
}
return o;
}
inline void operator<< (object::with_zone& o, const std::vector<bool>& v)
{
o.type = type::ARRAY;
if(v.empty()) {
o.via.array.ptr = nullptr;
o.via.array.size = 0;
} else {
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*v.size()));
object* const pend = p + v.size();
o.via.array.ptr = p;
o.via.array.size = v.size();
std::vector<bool>::const_iterator it(v.begin());
do {
*p = object(*it, o.zone);
++p;
++it;
} while(p < pend);
}
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack

View File

@ -28,6 +28,11 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
object const& operator>> (object const& o, std::vector<bool>& v);
template <typename Stream>
packer<Stream>& operator<< (packer<Stream>& o, const std::vector<bool>& v);
void operator<< (object::with_zone& o, const std::vector<bool>& v);
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack