[all-commits] [llvm/llvm-project] 205701: [llvm][ADT] Allow using structured bindings with `...

zero9178 via All-commits all-commits at lists.llvm.org
Tue Aug 9 09:12:55 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 205701fd47535a7525789f3291bd686cef1a9773
      https://github.com/llvm/llvm-project/commit/205701fd47535a7525789f3291bd686cef1a9773
  Author: Markus Böck <markus.boeck02 at gmail.com>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M llvm/include/llvm/ADT/STLExtras.h
    M llvm/unittests/ADT/STLExtrasTest.cpp

  Log Message:
  -----------
  [llvm][ADT] Allow using structured bindings with `llvm::enumerate`

This patch adds the ability to deconstruct the `value_type` returned by `llvm::enumarate` into index and value of the wrapping range. Main use case is the common occurence of using it during loop iteration. After this patch it'd then be possible to write code such as:
```
for (auto [index, value] : enumerate(container)) {
   ...
}
```
where `index` is the current index and `value` a reference to elements in the given container.

Differential Revision: https://reviews.llvm.org/D131486




More information about the All-commits mailing list