LLVM 24.0.0git
SmallVectorExtras.h
Go to the documentation of this file.
1//===- llvm/ADT/SmallVectorExtras.h -----------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file defines less commonly used SmallVector utilities.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ADT_SMALLVECTOREXTRAS_H
15#define LLVM_ADT_SMALLVECTOREXTRAS_H
16
17#include "llvm/ADT/STLExtras.h"
19
20namespace llvm {
21
22/// Filter a range to a SmallVector with the element types deduced.
23template <unsigned Size, class ContainerTy, class PredicateFn>
24auto filter_to_vector(ContainerTy &&C, PredicateFn &&Pred) {
25 return to_vector<Size>(make_filter_range(std::forward<ContainerTy>(C),
26 std::forward<PredicateFn>(Pred)));
27}
28
29/// Filter a range to a SmallVector with the element types deduced.
30template <class ContainerTy, class PredicateFn>
31auto filter_to_vector(ContainerTy &&C, PredicateFn &&Pred) {
32 return to_vector(make_filter_range(std::forward<ContainerTy>(C),
33 std::forward<PredicateFn>(Pred)));
34}
35
36/// Map a range to a SmallVector with element types deduced from the mapping.
37/// \p F can be a function, lambda, or member pointer.
38template <unsigned Size, class ContainerTy, class FuncTy>
39auto map_to_vector(ContainerTy &&C, FuncTy &&F) {
40 return to_vector<Size>(
41 map_range(std::forward<ContainerTy>(C), std::forward<FuncTy>(F)));
42}
43
44/// Map a range to a SmallVector with element types deduced from the mapping.
45/// \p F can be a function, lambda, or member pointer.
46template <class ContainerTy, class FuncTy>
47auto map_to_vector(ContainerTy &&C, FuncTy &&F) {
48 return to_vector(
49 map_range(std::forward<ContainerTy>(C), std::forward<FuncTy>(F)));
50}
51
52} // namespace llvm
53
54#endif // LLVM_ADT_SMALLVECTOREXTRAS_H
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define F(x, y, z)
Definition MD5.cpp:54
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallVector class.
This is an optimization pass for GlobalISel generic memory operations.
auto map_to_vector(ContainerTy &&C, FuncTy &&F)
Map a range to a SmallVector with element types deduced from the mapping.
auto map_range(ContainerTy &&C, FuncTy F)
Return a range that applies F to the elements of C.
Definition STLExtras.h:365
SmallVector< ValueTypeFromRangeType< R >, Size > to_vector(R &&Range)
Given a range of type R, iterate the entire range and return a SmallVector with elements of the vecto...
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
Definition STLExtras.h:551
auto filter_to_vector(ContainerTy &&C, PredicateFn &&Pred)
Filter a range to a SmallVector with the element types deduced.