Skip to content

Instantly share code, notes, and snippets.

@Aposhian
Created February 8, 2022 00:10
Show Gist options
  • Save Aposhian/4351f4824aafcce6bb9d645cc0952704 to your computer and use it in GitHub Desktop.
Save Aposhian/4351f4824aafcce6bb9d645cc0952704 to your computer and use it in GitHub Desktop.
test of std::transform behavior when start and end are the same
#include <algorithm>
#include <vector>
#include <iostream>
int main() {
std::vector<int> a = { 0, 1, 2, 3 };
std::vector<int> b;
std::transform(
a.begin(), a.begin(),
std::back_inserter(b),
[](const auto& x) {
return x;
}
);
std::cout << "a.size() = " << a.size() << std::endl
<< "b.size() = " << b.size() << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment