zeyi2 wrote:

Sorry for the late reply (for some reason I didn't get the notification)

> Is it okay to define a class with operator[]?

I think it would be better to use a mock std like this:

```c++
namespace std {
template <typename K, typename V>
struct map {
  V &operator[](const K &);
};
}
```

(Currently we still don't have `<map>` in clang-tidy's `input/headers`, so I 
guess we would have to mock this ourselves).

Then we could do something like:

```c++
template <typename T>
struct TemplateHolder : Base, T {
  std::map<Base *, int> M;
  void test() {
    auto &x = M[this];
    // no-warning here?
    (void)x;
  }
};
```

https://github.com/llvm/llvm-project/pull/187452
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to