Skip to content

Instantly share code, notes, and snippets.

@AndrewRademacher
Created May 5, 2019 17:46
Show Gist options
  • Save AndrewRademacher/123d069285104df206f6a41a82dea1a4 to your computer and use it in GitHub Desktop.
Save AndrewRademacher/123d069285104df206f6a41a82dea1a4 to your computer and use it in GitHub Desktop.
testing generically for proximity to the end of a structure.
#include <string>
#include <iostream>
#include <vector>
#include <array>
template<typename T>
void printElemes(T elems) {
std::cout << "[ ";
for (auto itr = elems.begin(); itr != elems.end(); ++itr) {
std::cout << *itr;
if (itr + 1 != elems.end()) std::cout << ", ";
}
std::cout << " ]\n";
}
int main() {
std::vector<uint64_t> vec{1, 2, 3, 4, 5, 6};
printElemes(vec);
std::array<uint64_t, 5> ary{1, 2, 3, 4, 5};
printElemes(ary);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment