Skip to content

Instantly share code, notes, and snippets.

@AndrewRademacher
Created May 5, 2019 17:40
Show Gist options
  • Save AndrewRademacher/64763480f1f67bc5589e0cf639b3ca4e to your computer and use it in GitHub Desktop.
Save AndrewRademacher/64763480f1f67bc5589e0cf639b3ca4e to your computer and use it in GitHub Desktop.
testing for proximity to the end of an iterator.
#include <string>
#include <iostream>
#include <vector>
int main() {
std::vector<uint64_t> elems{1, 2, 3, 4, 5, 6};
// print
std::cout << "[ ";
for (auto itr = elems.begin(); itr != elems.end(); ++itr) {
std::cout << *itr;
if (itr + 1 != elems.end()) std::cout << ", ";
}
std::cout << " ]";
return 0;
}
@AndrewRademacher
Copy link
Author

Results in (written to console):

[ 1, 2, 3, 4, 5, 6 ]

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