Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------
- equals_to_one_of.cpp
- -----------------------------------------------------------------------
- #include <cassert>
- #include <string>
- #include <string_view>
- template <typename T, typename... Args>
- bool EqualsToOneOf(const T& var, const Args&... args) {
- return ((var == args) || ...);
- }
- int main() {
- using namespace std::literals;
- assert(EqualsToOneOf("hello"sv, "hi"s, "hello"s));
- assert(!EqualsToOneOf(1, 10, 2, 3, 6));
- assert(!EqualsToOneOf(8));
- }
Advertisement
Add Comment
Please, Sign In to add comment