Last active
August 29, 2015 14:16
-
-
Save alepez/5c4ca1a35b22bbbe34eb to your computer and use it in GitHub Desktop.
pickRandom
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
template<typename T> | |
T pickRandom(std::vector<T>&& vec) { | |
return vec[::rand() % vec.size()]; | |
} | |
template<typename T> | |
T pickRandom(std::initializer_list<T>&& list) { | |
return pickRandom(std::vector<T>(std::move(list))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment