Skip to content

Commit 08669fb

Browse files
committed
[NFC][STLExtras] Add make_first_range(), similar to existing make_second_range()
Having just one of the two seens weird. I wanted to use it a few times, but it wasn't there.
1 parent 12e832c commit 08669fb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,15 @@ class indexed_accessor_range
12371237
}
12381238
};
12391239

1240+
/// Given a container of pairs, return a range over the first elements.
1241+
template <typename ContainerTy> auto make_first_range(ContainerTy &&c) {
1242+
return llvm::map_range(
1243+
std::forward<ContainerTy>(c),
1244+
[](decltype((*std::begin(c))) elt) -> decltype((elt.first)) {
1245+
return elt.first;
1246+
});
1247+
}
1248+
12401249
/// Given a container of pairs, return a range over the second elements.
12411250
template <typename ContainerTy> auto make_second_range(ContainerTy &&c) {
12421251
return llvm::map_range(

0 commit comments

Comments
 (0)