Question:
in C++ : Given the std::string s = "copyme" how can I make a string b which is "copymecopymecopyme" or any generalized s + s + ... n times?
possible solutions
A possible solution would be a method/macro that does a for loop, but that would be horribly inefficient.
What is an efficient method of doing this string copy operation, e.g. as the previous author says in the style of 'string'*n in python or ruby.
a relatively efficient loop would be allocating strlen*n and then copying the chars over multiple times rather than for(...) {str+=copy_this_string;} which does multiple copies and allocates.
another solution is using a stringbuffer.
SO clarifications
key: without using a macro. clarification: the 'char array' in the question is because in the original question, due to a single char in the string, all answers ignored the copying of a general stream and focused on using '.' since it had easily accessible methods such as the stream constructor.
"Duplicate" : How to repeat a string a variable number of times in C++? Except most the answers all used methods that only had a char repeated, e.g. the String Constructor and insert methods, which did not answer the original question and were unhelpful when I then looked for an efficient method.