Paul =?utf-8?q?Heidekrüger?= <paul.heidekrue...@tum.de>,
Paul =?utf-8?q?Heidekrüger?= <paul.heidekrue...@tum.de>,
Paul =?utf-8?q?Heidekrüger?= <paul.heidekrue...@tum.de>,
Paul =?utf-8?q?Heidekrüger?= <paul.heidekrue...@tum.de>,
Paul =?utf-8?q?Heidekrüger?= <paul.heidekrue...@tum.de>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/95...@github.com>


================
@@ -0,0 +1,31 @@
+.. title:: clang-tidy - cppcoreguidelines-prefer-at-over-subscript-operator
+
+cppcoreguidelines-prefer-at-over-subscript-operator
+=====================================
+
+This check flags all uses of ``operator[]`` where an equivalent (same 
parameter and return types) ``at()`` method exists and suggest using that 
instead.
+
+For example the code
+
+.. code-block:: c++
+  std::array<int, 3> a;
+  int b = a[4];
+
+will generate a warning but 
+
+.. code-block:: c++
+  std::unique_ptr<int> a;
+  int b = a[0];
+
+will not.
+
+The classes ``std::map``, ``std::unordered_map`` and ``std::flat_map`` are 
excluded from this check, because for them the subscript operator has a defined 
behaviour when a key does not exist (inserting a new element).
----------------
EugeneZelenko wrote:

Please follow 80 characters limit. Same in other places in this file.

https://github.com/llvm/llvm-project/pull/95220
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to