back_emplace_iterator and related classes and utility functions
Summary: C++ up to and including C++17 lacks an alternative to std::back_inserter() that uses emplace_back() instead of push_back(). This causes unnecessary temporary objects in some cases, when using std::back_inserter() together with STL functions such as std::copy() or std::transform(). The same holds for std::front_inserter() and std::inserter(). This diff introduces folly::back_emplacer(), folly::front_emplacer(), folly::emplacer(), and related iterator classes, which call emplace_back(), emplace_front(), and emplace() respectively, with perfect forwarding of any arguments to the output iterator's operator=. Includes support for variadic emplacement / multi-argument constructors through a utility function folly::make_emplace_args() which packs its arguments into a special tuple for use with operator=. Reviewed By: ericniebler Differential Revision: D4897174 fbshipit-source-id: c85c30c457e0c946938051819baa662d1a0b8ca1
Showing
folly/Iterator.h
0 → 100644
This diff is collapsed.
folly/test/IteratorTest.cpp
0 → 100644
This diff is collapsed.
Please register or sign in to comment