diff options
Diffstat (limited to 'libadhocutil/buffer.cpp')
-rw-r--r-- | libadhocutil/buffer.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libadhocutil/buffer.cpp b/libadhocutil/buffer.cpp index 07a57ea..e089c35 100644 --- a/libadhocutil/buffer.cpp +++ b/libadhocutil/buffer.cpp @@ -1,6 +1,7 @@ #include "buffer.h" #include <cstdio> #include <cstring> +#include <numeric> namespace AdHoc { @@ -241,11 +242,9 @@ namespace AdHoc { size_t Buffer::length() const { - size_t len = 0; - for (const Content::value_type & c : content) { - len += c->length(); - } - return len; + return std::accumulate(content.begin(), content.end(), 0U, [](auto && len, auto && c) { + return len + c->length(); + }); } Buffer & |