Advertisement
35657

Untitled

Sep 18th, 2023
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <cassert>
  2. #include <string>
  3. #include <string_view>
  4.  
  5. using namespace std;
  6.  
  7. template <typename T0, typename... Ts>
  8. bool EqualsToOneOf(const T0& v0, const Ts&... vs) {
  9.  
  10.     if constexpr (sizeof...(vs) != 0) {
  11.         return (v0 == vs) && EqualsToOneOf(v0, vs...);
  12.     }
  13.     return v0 == vs;
  14. }
  15.  
  16. int main() {
  17.     assert(EqualsToOneOf("hello"sv, "hi"s, "hello"s));
  18.     assert(!EqualsToOneOf(1, 10, 2, 3, 6));
  19.     assert(!EqualsToOneOf(8));
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement