include <string>

std::string operator*(std::string& s, unsigned int n)
{ std::string cml; cml.reserve(s.size() * n); for (decltype(n) i = 0; i < n; i++) { cml += s; } return cml; } int main() { std::string s = "test"; std::string sss = s*3; std::cout << sss << std::endl; }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.