io: return views from write wrappers
This commit is contained in:
parent
f94be34ae4
commit
f2fa90d043
13
io.hpp
13
io.hpp
@ -49,7 +49,7 @@ namespace util {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
inline void
|
inline void
|
||||||
write (const posix::fd &dst, util::view<const char*> data)
|
write (const posix::fd &dst, util::view<const uint8_t*> data)
|
||||||
{
|
{
|
||||||
write (dst, std::data (data), std::size (data));
|
write (dst, std::data (data), std::size (data));
|
||||||
}
|
}
|
||||||
@ -74,12 +74,13 @@ namespace util {
|
|||||||
/// in this event the progress may not be reported to the caller. in the
|
/// in this event the progress may not be reported to the caller. in the
|
||||||
/// future an exception member variable may expose the information.
|
/// future an exception member variable may expose the information.
|
||||||
template <typename DstT, typename IteratorA, typename IteratorB>
|
template <typename DstT, typename IteratorA, typename IteratorB>
|
||||||
void
|
util::view<IteratorA,IteratorB>
|
||||||
write (DstT &dst, util::view<IteratorA, IteratorB> src)
|
write (DstT &dst, const util::view<IteratorA, IteratorB> src)
|
||||||
{
|
{
|
||||||
for (auto cursor = src.begin (); cursor != src.end (); ) {
|
auto remain = src;
|
||||||
cursor = dst.write (view{cursor, src.end ()});
|
while (!remain.empty ())
|
||||||
}
|
remain = src - dst.write (remain);
|
||||||
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user