草庐IT

logAndAdd

全部标签

c++ - 当参数作为右值传递时完美转发避免复制?

我正在阅读Scott的书effectivemodernc++。在项目26中,有一个我在Wandbox上写的例子:https://wandbox.org/permlink/6DKoDqg4jAjA9ZTB我想验证好代码比坏代码好多少。然而,性能比较并不是我所期望的,即使是好的也比坏的慢。我不知道出了什么问题。为了防止wandbox的代码消失,这里是代码:#include#include#include#include#includeusingnamespacestd;std::multisetnames;voidbad_logAndAdd(conststd::string&name){a