Skip to content

Commit 20c35e8

Browse files
committed
#180-Implement CppStringT::operator* ()
Completed. Still to be tested.
1 parent fbde103 commit 20c35e8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cpp-strings/cppstrings.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,20 @@ namespace pcs // i.e. "pythonic c++ strings"
12471247
}
12481248

12491249

1250+
//--- operator * --------------------------------------
1251+
/** Generates a new string with count times the content of this string. */
1252+
CppStringT operator* (std::int64_t count) const noexcept
1253+
{
1254+
if (count <= 0)
1255+
return CppStringT();
1256+
1257+
CppStringT res( *this );
1258+
while (--count)
1259+
res += *this;
1260+
return res;
1261+
}
1262+
1263+
12501264
//--- partition() -------------------------------------
12511265
/** Splits the string at the first occurrence of sep, and returns a 3-items vector containing the part before the separator, the separator itself, and the part after the separator.
12521266
*

0 commit comments

Comments
 (0)