Igor R
2013-03-12 09:53:27 UTC
Hello,
In the current implementation the following code would compile, but produce UB:
string s = "a string";
vector<const_buffer> v;
v.push_back(buffer(s));
write(socket_, buffer(vec)); // NOTE incorrect buffer(); should be
just write(socket_, vec);
Isn't it worth trying to protect such a missuse by
enable_if<is_pod<.....> >? Like this:
template <typename PodType, typename Allocator>
inline mutable_buffers_1 buffer(std::vector<PodType, Allocator>& data,
typename boost::enable_if<boost::is_pod<PodType> >::type *t = 0)
{
....
}
Thanks.
In the current implementation the following code would compile, but produce UB:
string s = "a string";
vector<const_buffer> v;
v.push_back(buffer(s));
write(socket_, buffer(vec)); // NOTE incorrect buffer(); should be
just write(socket_, vec);
Isn't it worth trying to protect such a missuse by
enable_if<is_pod<.....> >? Like this:
template <typename PodType, typename Allocator>
inline mutable_buffers_1 buffer(std::vector<PodType, Allocator>& data,
typename boost::enable_if<boost::is_pod<PodType> >::type *t = 0)
{
....
}
Thanks.