Browse Source

Add support for container searching in matcher

Sam Jaffe 6 years ago
parent
commit
d57ba65b6b
1 changed files with 17 additions and 0 deletions
  1. 17 0
      match.hpp

+ 17 - 0
match.hpp

@@ -35,6 +35,23 @@ namespace matcher {
   }
 }
 
+namespace matcher {
+  template <typename Container>
+  struct any_in_t {
+    Container options;
+  };
+  
+  template <typename T, typename Container>
+  bool operator==(T const & t, any_in_t<Container> const & of) {
+    return std::find(of.options.begin(), of.options.end(), t) != of.options.end();
+  }
+  
+  template <typename Container>
+  any_in_t<Container> any_in(Container && args) {
+    return {args};
+  }
+}
+
 namespace matcher {
   template <typename... Args>
   struct matcher {