Guitar
npos.h
Go to the documentation of this file.
1 #ifndef NPOS_H
2 #define NPOS_H
3 
4 #include <string>
5 #include <limits>
6 #include <type_traits>
7 
8 #if 0
9 struct NPOS_t {
10  template <typename T>
11  friend constexpr bool operator == (T x, NPOS_t)
12  {
13  return x == std::numeric_limits<T>::max();
14  }
15 
16  template <typename T>
17  friend constexpr bool operator != (T x, NPOS_t)
18  {
19  return x != std::numeric_limits<T>::max();
20  }
21 };
22 
23 inline constexpr NPOS_t NPOS;
24 #endif
25 
26 class FOUND {
27 private:
28  bool found_ = false;
29 public:
30  explicit FOUND(std::string::size_type t)
31  {
32  found_ = (t != std::string::npos);
33  }
34  template <typename T, typename U> FOUND(T t, U const &u)
35  {
36  found_ = (t != u.end());
37  }
38  explicit operator bool () const
39  {
40  return found_;
41  }
42 };
43 
44 #endif // NPOS_H
static bool operator==(GitHash const &l, GitHash const &r)
Definition: GitTypes.h:59
static bool operator!=(GitHash const &l, GitHash const &r)
Definition: GitTypes.h:64
Definition: npos.h:26
FOUND(T t, U const &u)
Definition: npos.h:34
FOUND(std::string::size_type t)
Definition: npos.h:30
bool found_
Definition: npos.h:28