[cfe-dev] Transforming push_back(T(args, ...)) into emplace_back(args)
Vedant Kumar via cfe-dev
cfe-dev at lists.llvm.org
Thu Apr 28 19:00:33 PDT 2016
It's common to see code which does this:
(1) V.push_back(T(args, ...));
When it could do this instead:
(2) V.emplace_back(args, ...);
IIUC, the copy constructor for T is never called in case (2).
Would it be possible/worthwhile/correctness-preserving to perform this transformation in clang? Based on a cursory grep it doesn't seem like we do this today, but I could've missed something.
More information about the cfe-dev