From f2fa90d0430e2dbf7dffd0e1704b586890ccbb40 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 28 Dec 2017 17:49:58 +1100 Subject: [PATCH] io: return views from write wrappers --- io.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/io.hpp b/io.hpp index 8582748b..4ed8a543 100644 --- a/io.hpp +++ b/io.hpp @@ -49,7 +49,7 @@ namespace util { //------------------------------------------------------------------------- inline void - write (const posix::fd &dst, util::view data) + write (const posix::fd &dst, util::view 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 /// future an exception member variable may expose the information. template - void - write (DstT &dst, util::view src) + util::view + write (DstT &dst, const util::view src) { - for (auto cursor = src.begin (); cursor != src.end (); ) { - cursor = dst.write (view{cursor, src.end ()}); - } + auto remain = src; + while (!remain.empty ()) + remain = src - dst.write (remain); + return src; }