Skip to content

Commit

Permalink
transform_to: return target collection
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Jan 22, 2025
1 parent 3037460 commit b3fcf40
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/utl/to_vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
namespace utl {

template <typename Output, typename Container, typename UnaryOperation>
inline void transform_to(Container&& c, Output& out, UnaryOperation&& op) {
inline Output& transform_to(Container&& c, Output& out, UnaryOperation&& op) {
using std::begin;
using std::end;
out.reserve(static_cast<std::size_t>(std::distance(begin(c), end(c))));
std::transform(begin(c), end(c), std::back_inserter(out),
std::forward<UnaryOperation>(op));
return out;
}

template <typename Output, typename Container, typename UnaryOperation>
Expand Down

0 comments on commit b3fcf40

Please sign in to comment.