From d9bd0f83800e8645368ed6430a914e84b53ac227 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 21 May 2016 15:36:14 +0100 Subject: [PATCH] restrict string operator+ (conflicts with range offset) --- ostd/string.hh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ostd/string.hh b/ostd/string.hh index c3bbcb1..102fe2b 100644 --- a/ostd/string.hh +++ b/ostd/string.hh @@ -910,7 +910,19 @@ String to_string(std::initializer_list init) { /* TODO: rvalue ref versions for rhs when we have efficient prepend */ -inline String operator+(ConstCharRange lhs, ConstCharRange rhs) { +inline String operator+(const String &lhs, ConstCharRange rhs) { + String ret(lhs); ret += rhs; return ret; +} + +inline String operator+(ConstCharRange lhs, const String &rhs) { + String ret(lhs); ret += rhs; return ret; +} + +inline String operator+(const String &lhs, char rhs) { + String ret(lhs); ret += rhs; return ret; +} + +inline String operator+(char lhs, const String &rhs) { String ret(lhs); ret += rhs; return ret; } @@ -918,18 +930,10 @@ 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: