From 60a04937c6c6f7fb32c4e5793f5ebe1e0a95fc1b Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 23 Mar 2016 22:32:30 +0000 Subject: [PATCH] string range optimizations --- ostd/string.hh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ostd/string.hh b/ostd/string.hh index b69b299..21be612 100644 --- a/ostd/string.hh +++ b/ostd/string.hh @@ -165,6 +165,17 @@ public: return ret ? ret : (size() - s.size()); } + template + EnableIf, Size> copy(R &&orange, Size n = -1) { + return orange.put_n(data(), ostd::min(n, size())); + } + + Size copy(RemoveCv *p, Size n = -1) { + Size c = ostd::min(n, size()); + memcpy(p, data(), c * sizeof(T)); + return c; + } + private: T *p_beg, *p_end; };