Skip to content

Conversation

@seanpquinn
Copy link

closes #151

std::vector<int> array;
array.reserve(N);
for (j = 0; j < N; ++j) array[j] = j;
for (j = 0; j < N; ++j) array.push_back(j);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that push_back here is useless, because array.reserve already reserves the space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential crash: std::vector::resize and std::vector::reserve

2 participants