How can we use std::transform
, if we don't want to transform each element into one transformed element, but two?
The following pseudo code illustrates what I want to achieve
std::transform(a.cbegin(), a.cend(), std::back_inserter(b), [](T const& x) {
return f(x) and g(x);
});
Of course, I could invoke std::transform
two times, but that would be annoying. Maybe we need to provide a custom inserter. Any other option?
Aucun commentaire:
Enregistrer un commentaire