我找到了我 friend 的 Qt 代码,他在两个 QString
上使用模运算符,如下所示:
QString result = oneString % twoString;
这是什么意思?
最佳答案
这只是连接 QString
的另一种(更有效的)方式,如 the manual 中所述。
QStringBuilder uses expression templates and reimplements the '%' operator so that when you use '%' for string concatenation instead of '+', multiple substring concatenations will be postponed until the final result is about to be assigned to a QString. At this point, the amount of memory required for the final result is known. The memory allocator is then called once to get the required space, and the substrings are copied into it one by one.
关于c++ - 带有字符串的奇怪 Qt 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12027977/