MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / ExprIdToken

Class ExprIdToken

lib/programmemory.h:40–102  ·  view source on GitHub ↗

Class used to handle heterogeneous lookup in unordered_map(since we can't use C++20 yet)

Source from the content-addressed store, hash-verified

38
39// Class used to handle heterogeneous lookup in unordered_map(since we can't use C++20 yet)
40struct ExprIdToken {
41 const Token* tok = nullptr;
42 nonneg int exprid = 0;
43
44 // cppcheck-suppress noExplicitConstructor
45 // NOLINTNEXTLINE(google-explicit-constructor)
46 ExprIdToken(const Token* tok);
47
48 nonneg int getExpressionId() const;
49
50 bool operator==(const ExprIdToken& rhs) const {
51 return getExpressionId() == rhs.getExpressionId();
52 }
53
54 bool operator<(const ExprIdToken& rhs) const {
55 return getExpressionId() < rhs.getExpressionId();
56 }
57
58 template<class T, class U>
59 friend bool operator!=(const T& lhs, const U& rhs)
60 {
61 return !(lhs == rhs);
62 }
63
64 template<class T, class U>
65 friend bool operator<=(const T& lhs, const U& rhs)
66 {
67 return !(lhs > rhs);
68 }
69
70 template<class T, class U>
71 friend bool operator>(const T& lhs, const U& rhs)
72 {
73 return rhs < lhs;
74 }
75
76 template<class T, class U>
77 friend bool operator>=(const T& lhs, const U& rhs)
78 {
79 return !(lhs < rhs);
80 }
81
82 const Token& operator*() const noexcept {
83 return *tok;
84 }
85
86 const Token* operator->() const noexcept {
87 return tok;
88 }
89
90 struct Hash {
91 std::size_t operator()(ExprIdToken etok) const;
92 };
93
94 /** create object for hashed lookups */
95 static ExprIdToken create(nonneg int exprId) {
96 return ExprIdToken(exprId);
97 }

Callers 1

createMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected