Skip to content

Instantly share code, notes, and snippets.

@tau0
Created June 11, 2014 10:37
Show Gist options
  • Save tau0/2b156c3b47a875808134 to your computer and use it in GitHub Desktop.
Save tau0/2b156c3b47a875808134 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
vector<int> doubleValues (const vector<int>& v)
{
vector<int> new_values;
new_values.reserve();
for (auto itr = v.begin(), end_itr = v.end(); itr != end_itr; ++itr )
{
new_values.push_back( 2 * *itr );
}
return new_values;
}
int main()
{
vector<int> v;
for ( int i = 0; i < 100; i++ )
{
v.push_back( i );
}
v = doubleValues( v );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment