Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:08

0001 //===- llvm/ADT/SmallVectorExtras.h -----------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file
0010 /// This file defines less commonly used SmallVector utilities.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_ADT_SMALLVECTOREXTRAS_H
0015 #define LLVM_ADT_SMALLVECTOREXTRAS_H
0016 
0017 #include "llvm/ADT/STLExtras.h"
0018 #include "llvm/ADT/SmallVector.h"
0019 
0020 namespace llvm {
0021 
0022 /// Filter a range to a SmallVector with the element types deduced.
0023 template <unsigned Size, class ContainerTy, class PredicateFn>
0024 auto filter_to_vector(ContainerTy &&C, PredicateFn &&Pred) {
0025   return to_vector<Size>(make_filter_range(std::forward<ContainerTy>(C),
0026                                            std::forward<PredicateFn>(Pred)));
0027 }
0028 
0029 /// Filter a range to a SmallVector with the element types deduced.
0030 template <class ContainerTy, class PredicateFn>
0031 auto filter_to_vector(ContainerTy &&C, PredicateFn &&Pred) {
0032   return to_vector(make_filter_range(std::forward<ContainerTy>(C),
0033                                      std::forward<PredicateFn>(Pred)));
0034 }
0035 
0036 /// Map a range to a SmallVector with element types deduced from the mapping.
0037 template <unsigned Size, class ContainerTy, class FuncTy>
0038 auto map_to_vector(ContainerTy &&C, FuncTy &&F) {
0039   return to_vector<Size>(
0040       map_range(std::forward<ContainerTy>(C), std::forward<FuncTy>(F)));
0041 }
0042 
0043 /// Map a range to a SmallVector with element types deduced from the mapping.
0044 template <class ContainerTy, class FuncTy>
0045 auto map_to_vector(ContainerTy &&C, FuncTy &&F) {
0046   return to_vector(
0047       map_range(std::forward<ContainerTy>(C), std::forward<FuncTy>(F)));
0048 }
0049 
0050 } // namespace llvm
0051 
0052 #endif // LLVM_ADT_SMALLVECTOREXTRAS_H