any_of.hpp 484 B

1234567891011121314151617181920
  1. #pragma once
  2. #include <array>
  3. namespace matcher {
  4. template <typename T, size_t I>
  5. struct any_of_t {
  6. std::array<T, I> options;
  7. };
  8. template <typename T, size_t I>
  9. bool operator==(T const & t, any_of_t<T, I> const & of) {
  10. return std::find(of.options.begin(), of.options.end(), t) != of.options.end();
  11. }
  12. template <typename... Args>
  13. any_of_t<typename std::common_type<Args...>::type, sizeof...(Args)> any_of(Args &&... args) {
  14. return {{args...}};
  15. }
  16. }