-
Notifications
You must be signed in to change notification settings - Fork 930
Closed
Description
I see there is fixes for correct type cast.
Previously within pack.hpp was declaraion:
void append_buffer(const char* buf, size_t len)
{ m_stream.write(buf, len); }
Now there is couple of compile time overloads to respect valid type cast when len parameter is not size_t. But, what if method ::write has overloads ? In this case &Stream::write will not be compiled (because compiler has ambiguity).
I have class Writer with 'primary' write method
virtual void write(const std::byte*, size_t size) = 0;
and second 'utility' method:
void write(const char* bytes, size_t size)
{
write(reinterpret_cast<const std::byte*>(bytes), size);
}
Second method introduced especially to using with msgpack-c, but for first parameter compatibility. As temporary solution i remove second 'utility' method from my Writer class and 'fix' pack.hpp as
void append_buffer(const char* buf, size_t len)
{
append_buffer(m_stream, &Stream::write, buf, len);
}
template<typename S, typename R, typename Ptr, typename Size>
static void append_buffer(S& s, R (S::*) (Ptr, Size), const char* buf, size_t len)
{
s.write(reinterpret_cast<Ptr>(buf), static_cast<Size>(len));
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels