https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63753

            Bug ID: 63753
           Summary: std::transform does not change size
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: darkdragon-001 at web dot de

When using std::transform with a OutputIterator to std::vector then the vector
size is not updated (see code attached):

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<double> v = {1,2,3,4,5};
  vector<double> r;
  r.reserve(v.size());
  transform(v.begin(),v.end(),r.begin(),[](const double& d) {
    return 2*d;
  });
  cout << "size:" << r.size() << "front:" << r.front() << endl;

  return 0;
}

Reply via email to