通常,人们可以这样做:
string a;
a = {a, " first"};
a = {a, " second"};
a = {a, " third"};
据我了解,这意味着a
每次都为连接的字符串连续重新分配。是否有一个神奇的join
函数可以像这样工作,使其性能更高?
string a;
string a_q[$];
a_q = '{"first", "second", "third"};
a = a_q.join(); // a = {a_q} doesn't work as {a_q} returns another queue;
答案 0 :(得分:0)
您可以使用位流投射:(LRM第6.24.3节“位流投射”)
a = string'(a_q);