Is.h
Go to the documentation of this file.
1 #ifndef _utl_Is_h_
2 #define _utl_Is_h_
3 
4 #include <string>
5 
6 
7 namespace utl {
8 
15  template<typename T>
16  struct IsProxy {
17  IsProxy(const T& x) : fX(x) { }
18 
19  template<class Container>
20  bool In(const Container& c) const
21  { return c.find(fX) != c.end(); }
22 
23  bool In(const std::string& s) const
24  { return s.find(fX) != std::string::npos; }
25 
26  template<class Container>
27  bool NotIn(const Container& c) const
28  { return !In(c); }
29 
30  template<typename U, typename W>
31  bool InRange(const U& a, const W& b) const
32  { return a <= fX && fX <= b; }
33 
34  template<typename U, typename W>
35  bool InsideRange(const U& a, const W& b) const
36  { return a < fX && fX < b; }
37 
38  private:
39  const T& fX;
40  };
41 
42 
43  template<typename T>
44  inline
46  Is(const T& x)
47  {
48  return IsProxy<T>(x);
49  }
50 
51 }
52 
53 
54 #endif
bool NotIn(const Container &c) const
Definition: Is.h:27
bool InsideRange(const U &a, const W &b) const
Definition: Is.h:35
IsProxy< T > Is(const T &x)
Definition: Is.h:46
IsProxy(const T &x)
Definition: Is.h:17
#define U
constexpr double s
Definition: AugerUnits.h:163
bool In(const Container &c) const
Definition: Is.h:20
bool In(const std::string &s) const
Definition: Is.h:23
bool InRange(const U &a, const W &b) const
Definition: Is.h:31
const T & fX
Definition: Is.h:39

, generated on Tue Sep 26 2023.