Created
November 18, 2023 20:13
-
-
Save jimdiroffii/3f8a4d052a47048ddc4e6be8bf7b3860 to your computer and use it in GitHub Desktop.
C++ :: Templated vector print function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit: @bweinman | C++ Templates and the STL | |
// printv() iterates a vector, printing space separated elements | |
template<type T> | |
void printv(vector<T> &v) { | |
if(v.empty()) return; | |
for(T &i : v) cout << i << " "; | |
cout << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment