From a5c4b9d3ca72a89ff8911f77ed6f469c1cf5d321 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 7 May 2016 17:25:40 +0100 Subject: [PATCH] global concat op for strings --- ostd/string.hh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ostd/string.hh b/ostd/string.hh index 605f222..c3bbcb1 100644 --- a/ostd/string.hh +++ b/ostd/string.hh @@ -908,6 +908,28 @@ String to_string(std::initializer_list init) { return to_string(iter(init)); } +/* TODO: rvalue ref versions for rhs when we have efficient prepend */ + +inline String operator+(ConstCharRange lhs, ConstCharRange rhs) { + String ret(lhs); ret += rhs; return ret; +} + +inline String operator+(String &&lhs, ConstCharRange rhs) { + String ret(move(lhs)); ret += rhs; return ret; +} + +inline String operator+(ConstCharRange lhs, char rhs) { + String ret(lhs); ret += rhs; return ret; +} + +inline String operator+(String &&lhs, char rhs) { + String ret(move(lhs)); ret += rhs; return ret; +} + +inline String operator+(char lhs, ConstCharRange rhs) { + String ret(lhs); ret += rhs; return ret; +} + template struct TempCString { private: