@@ -377,6 +377,70 @@ bool TypeIsAssignable(const Type& to, const Type& from);
377377
378378} // namespace common_internal
379379
380+ struct VariableDeclEqualTo {
381+ using is_transparent = void ;
382+
383+ bool operator ()(const cel::VariableDecl& lhs,
384+ const cel::VariableDecl& rhs) const {
385+ return lhs.name () == rhs.name ();
386+ }
387+
388+ bool operator ()(const cel::VariableDecl& lhs, std::string_view rhs) const {
389+ return lhs.name () == rhs;
390+ }
391+
392+ bool operator ()(std::string_view lhs, const cel::VariableDecl& rhs) const {
393+ return lhs == rhs.name ();
394+ }
395+ };
396+
397+ struct VariableDeclHash {
398+ using is_transparent = void ;
399+
400+ size_t operator ()(const cel::VariableDecl& decl) const {
401+ return (*this )(decl.name ());
402+ }
403+
404+ size_t operator ()(std::string_view name) const { return absl::HashOf (name); }
405+ };
406+
407+ using VariableDeclSet = absl::flat_hash_set<cel::VariableDecl, VariableDeclHash,
408+ VariableDeclEqualTo>;
409+
410+ struct FunctionDeclEqualTo {
411+ using is_transparent = void ;
412+
413+ bool operator ()(const cel::FunctionDecl& lhs,
414+ const cel::FunctionDecl& rhs) const {
415+ return (*this )(lhs.name (), rhs.name ());
416+ }
417+
418+ bool operator ()(const cel::FunctionDecl& lhs, std::string_view rhs) const {
419+ return (*this )(lhs.name (), rhs);
420+ }
421+
422+ bool operator ()(std::string_view lhs, const cel::FunctionDecl& rhs) const {
423+ return (*this )(lhs, rhs.name ());
424+ }
425+
426+ bool operator ()(std::string_view lhs, std::string_view rhs) const {
427+ return lhs == rhs;
428+ }
429+ };
430+
431+ struct FunctionDeclHash {
432+ using is_transparent = void ;
433+
434+ size_t operator ()(const cel::FunctionDecl& decl) const {
435+ return absl::HashOf (decl.name ());
436+ }
437+
438+ size_t operator ()(std::string_view name) const { return absl::HashOf (name); }
439+ };
440+
441+ using FunctionDeclSet = absl::flat_hash_set<cel::FunctionDecl, FunctionDeclHash,
442+ FunctionDeclEqualTo>;
443+
380444} // namespace cel
381445
382446#endif // THIRD_PARTY_CEL_CPP_COMMON_DECL_H_
0 commit comments