17 #ifndef LLVM_ADT_STLEXTRAS_H 18 #define LLVM_ADT_STLEXTRAS_H 24 #include "llvm/Config/abi-breaking.h" 32 #include <initializer_list> 37 #include <type_traits> 40 #ifdef EXPENSIVE_CHECKS 52 template <
typename RangeT>
55 template <
typename RangeT>
56 using ValueOfRange =
typename std::remove_reference<decltype(
66 struct negation : std::integral_constant<bool, !bool(T::value)> {};
68 template <
typename...>
struct conjunction : std::true_type {};
70 template <
typename B1,
typename... Bn>
72 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>
::type {};
76 typename std::add_pointer<typename std::add_const<T>::type>
::type;
80 using type =
typename std::add_lvalue_reference<
81 typename std::add_const<T>::type>
::type;
101 return *left < *right;
107 return *right < *left;
119 template<
typename Ret,
typename ...Params>
121 Ret (*callback)(
intptr_t callable, Params ...params) =
nullptr;
124 template<
typename Callable>
125 static Ret callback_fn(
intptr_t callable, Params ...params) {
126 return (*reinterpret_cast<Callable*>(callable))(
127 std::forward<Params>(params)...);
134 template <
typename Callable>
136 typename std::enable_if<
137 !std::is_same<
typename std::remove_reference<Callable>::type,
139 : callback(callback_fn<typename
std::remove_reference<Callable>::
type>),
140 callable(reinterpret_cast<
intptr_t>(&callable)) {}
143 return callback(callable, std::forward<Params>(params)...);
146 operator bool()
const {
return callback; }
162 namespace adl_detail {
166 template <
typename ContainerTy>
168 -> decltype(
begin(std::forward<ContainerTy>(container))) {
169 return begin(std::forward<ContainerTy>(container));
174 template <
typename ContainerTy>
176 -> decltype(
end(std::forward<ContainerTy>(container))) {
177 return end(std::forward<ContainerTy>(container));
182 template <
typename T>
184 std::declval<T>()))) {
185 swap(std::forward<T>(lhs), std::forward<T>(rhs));
190 template <
typename ContainerTy>
196 template <
typename ContainerTy>
202 template <
typename T>
209 template <
typename T>
210 constexpr
bool empty(
const T &RangeOrContainer) {
217 template <
typename ItTy,
typename FuncTy,
218 typename FuncReturnTy =
219 decltype(std::declval<FuncTy>()(*std::declval<ItTy>()))>
222 mapped_iterator<ItTy, FuncTy>, ItTy,
223 typename std::iterator_traits<ItTy>::iterator_category,
224 typename std::remove_reference<FuncReturnTy>::type> {
239 template <
class ItTy,
class FuncTy>
249 template <
typename Inner>
250 static yes& test(Inner *
I, decltype(I->rbegin()) * =
nullptr);
253 static no& test(...);
256 static const bool value =
sizeof(test<Ty>(
nullptr)) ==
sizeof(yes);
260 template <
typename Ty>
266 template <
typename ContainerTy>
269 nullptr) -> decltype(
make_range(
C.rbegin(),
C.rend())) {
274 template <
typename IteratorTy>
276 return std::reverse_iterator<IteratorTy>(It);
282 template <
typename ContainerTy>
308 template <
typename WrappedIteratorT,
typename PredicateT,
typename IterTag>
311 filter_iterator_base<WrappedIteratorT, PredicateT, IterTag>,
313 typename std::common_type<
314 IterTag, typename std::iterator_traits<
315 WrappedIteratorT>::iterator_category>::type> {
319 typename std::common_type<
320 IterTag,
typename std::iterator_traits<
321 WrappedIteratorT>::iterator_category>
::type>;
328 while (this->
I != End && !Pred(*this->
I))
337 : BaseT(Begin), End(End), Pred(Pred) {
342 using BaseT::operator++;
352 template <
typename WrappedIteratorT,
typename PredicateT,
353 typename IterTag = std::forward_iterator_tag>
361 :
BaseT(Begin, End, Pred) {}
365 template <
typename WrappedIteratorT,
typename PredicateT>
367 std::bidirectional_iterator_tag>
369 std::bidirectional_iterator_tag> {
371 std::bidirectional_iterator_tag>;
372 void findPrevValid() {
373 while (!this->Pred(*this->
I))
378 using BaseT::operator--;
382 : BaseT(Begin, End, Pred) {}
394 using type = std::forward_iterator_tag;
398 using type = std::bidirectional_iterator_tag;
406 std::bidirectional_iterator_tag,
407 typename std::iterator_traits<IterT>::iterator_category>::value>
::type;
414 template <
typename WrappedIteratorT,
typename PredicateT>
416 WrappedIteratorT, PredicateT,
426 template <
typename RangeT,
typename PredicateT>
429 using FilterIteratorT =
432 FilterIteratorT(
std::begin(std::forward<RangeT>(Range)),
433 std::end(std::forward<RangeT>(Range)), Pred),
434 FilterIteratorT(
std::end(std::forward<RangeT>(Range)),
435 std::end(std::forward<RangeT>(Range)), Pred));
455 template <
typename WrappedIteratorT>
458 WrappedIteratorT, std::input_iterator_tag> {
461 WrappedIteratorT, std::input_iterator_tag>;
463 using PointerT =
typename std::iterator_traits<WrappedIteratorT>::pointer;
466 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 467 bool IsEarlyIncremented =
false;
473 using BaseT::operator*;
475 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 476 assert(!IsEarlyIncremented &&
"Cannot dereference twice!");
477 IsEarlyIncremented =
true;
482 using BaseT::operator++;
484 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 485 assert(IsEarlyIncremented &&
"Cannot increment before dereferencing!");
486 IsEarlyIncremented =
false;
491 using BaseT::operator==;
493 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 494 assert(!IsEarlyIncremented &&
"Cannot compare after dereferencing!");
512 template <
typename RangeT>
515 using EarlyIncIteratorT =
518 EarlyIncIteratorT(
std::end(std::forward<RangeT>(Range))));
522 template <
typename R,
typename UnaryPredicate>
523 bool all_of(R &&range, UnaryPredicate
P);
524 template <
typename R,
typename UnaryPredicate>
525 bool any_of(R &&range, UnaryPredicate P);
538 using type = std::tuple<decltype(*declval<Iters>())...>;
541 template <
typename ZipType,
typename... Iters>
543 ZipType,
typename std::common_type<std::bidirectional_iterator_tag,
544 typename std::iterator_traits<
545 Iters>::iterator_category...>
::type,
548 typename std::iterator_traits<
typename std::tuple_element<
549 0, std::tuple<Iters...>>
::type>::difference_type,
557 template <
typename ZipType,
typename... Iters>
559 using Base = zip_traits<ZipType, Iters...>;
566 return value_type(*std::get<Ns>(iterators)...);
569 template <
size_t... Ns>
571 return std::tuple<Iters...>(std::next(std::get<Ns>(iterators))...);
574 template <
size_t... Ns>
576 return std::tuple<Iters...>(std::prev(std::get<Ns>(iterators))...);
590 return *
reinterpret_cast<ZipType *
>(
this);
594 static_assert(Base::IsBidirectional,
595 "All inner iterators must be at least bidirectional.");
597 return *
reinterpret_cast<ZipType *
>(
this);
601 template <
typename... Iters>
606 return std::get<0>(this->iterators) == std::get<0>(other.
iterators);
612 template <
typename... Iters>
614 template <
size_t... Ns>
616 return all_of(std::initializer_list<bool>{std::get<Ns>(this->iterators) !=
641 std::tuple<
Args...> ts;
660 template <
typename T,
typename U,
typename...
Args>
664 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(args)...);
669 template <
typename T,
typename U,
typename...
Args>
673 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(args)...);
677 template <
typename Iter>
684 template <
typename Iter>
687 typename std::remove_reference<decltype(*I)>::type>
::type> {
695 llvm::Optional<
typename std::remove_const<
typename std::remove_reference<
700 using type = std::tuple<typename ZipLongestItemType<Iters>::type...>;
703 template <
typename... Iters>
706 zip_longest_iterator<Iters...>,
707 typename std::common_type<
708 std::forward_iterator_tag,
709 typename std::iterator_traits<Iters>::iterator_category...>::type,
710 typename ZipLongestTupleType<Iters...>::type,
711 typename std::iterator_traits<typename std::tuple_element<
712 0, std::tuple<Iters...>>::type>::difference_type,
713 typename ZipLongestTupleType<Iters...>::type *,
714 typename ZipLongestTupleType<Iters...>::type> {
719 std::tuple<Iters...> iterators;
720 std::tuple<Iters...> end_iterators;
722 template <
size_t... Ns>
726 std::initializer_list<bool>{std::get<Ns>(this->iterators) !=
727 std::get<Ns>(other.iterators)...},
733 deref_or_none(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
736 template <
size_t... Ns>
738 return std::tuple<Iters...>(
739 next_or_end(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
744 : iterators(
std::forward<Iters>(ts.
first)...),
745 end_iterators(
std::forward<Iters>(ts.
second)...) {}
772 std::tuple<
Args...> ts;
776 adl_end(std::get<Ns>(ts)))...);
781 adl_end(std::get<Ns>(ts)))...);
795 template <
typename T,
typename U,
typename...
Args>
799 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(args)...);
812 template <
typename ValueT,
typename... IterTs>
815 std::forward_iterator_tag, ValueT> {
816 using BaseT =
typename concat_iterator::iterator_facade_base;
824 std::tuple<IterTs...> Begins;
825 std::tuple<IterTs...> Ends;
831 template <
size_t Index>
bool incrementHelper() {
832 auto &Begin = std::get<Index>(Begins);
833 auto &End = std::get<Index>(Ends);
847 &concat_iterator::incrementHelper<Ns>...};
850 for (
auto &IncrementHelperFn : IncrementHelperFns)
851 if ((this->*IncrementHelperFn)())
860 template <
size_t Index>
ValueT *getHelper()
const {
861 auto &Begin = std::get<Index>(Begins);
862 auto &End = std::get<Index>(Ends);
876 &concat_iterator::getHelper<Ns>...};
879 for (
auto &GetHelperFn : GetHelperFns)
880 if (
ValueT *
P = (this->*GetHelperFn)())
883 llvm_unreachable(
"Attempted to get a pointer from an end concat iterator!");
891 template <
typename... RangeTs>
895 using BaseT::operator++;
905 return Begins == RHS.Begins && Ends == RHS.Ends;
923 std::tuple<RangeTs...> Ranges;
926 return iterator(std::get<Ns>(Ranges)...);
930 std::end(std::get<Ns>(Ranges)))...);
935 : Ranges(
std::forward<RangeTs>(Ranges)...) {}
946 template <
typename ValueT,
typename... RangeTs>
948 static_assert(
sizeof...(RangeTs) > 1,
949 "Need more than one range to concatenate!");
951 std::forward<RangeTs>(Ranges)...);
961 template <
typename T>
bool operator()(
const T &lhs,
const T &rhs)
const {
962 return lhs.first < rhs.first;
969 template <
typename T>
bool operator()(
const T &lhs,
const T &rhs)
const {
970 return lhs.second < rhs.second;
976 template<
typename FuncTy>
980 template <
typename T>
982 -> decltype(func(lhs.first, rhs.first)) {
983 return func(lhs.first, rhs.first);
993 static constexpr
size_t size() {
return sizeof...(I); }
997 template <
size_t...
I>
1000 template <std::size_t
N, std::size_t...
I>
1002 template <std::size_t...
I>
1006 template <
class... Ts>
1017 static const bool value =
false;
1020 template <
typename T,
typename U,
typename... Ts>
1022 static const bool value =
1023 std::is_same<T, U>::value ||
is_one_of<
T, Ts...>::value;
1029 static const bool value =
true;
1032 template <
typename T,
typename U,
typename... Ts>
1034 static const bool value =
1035 std::is_base_of<T, U>::value &&
are_base_of<
T, Ts...>::value;
1043 template <
class T, std::
size_t N>
1049 template<
typename T>
1051 if (std::less<T>()(*reinterpret_cast<const T*>(P1),
1052 *reinterpret_cast<const T*>(P2)))
1054 if (std::less<T>()(*reinterpret_cast<const T*>(P2),
1055 *reinterpret_cast<const T*>(P1)))
1062 template<
typename T>
1064 (
const void*,
const void*) {
1065 return array_pod_sort_comparator<T>;
1082 template<
class IteratorTy>
1086 auto NElts = End - Start;
1087 if (NElts <= 1)
return;
1088 #ifdef EXPENSIVE_CHECKS 1089 std::mt19937 Generator(std::random_device{}());
1090 std::shuffle(Start, End, Generator);
1095 template <
class IteratorTy>
1097 IteratorTy Start, IteratorTy End,
1099 const typename std::iterator_traits<IteratorTy>::value_type *,
1100 const typename std::iterator_traits<IteratorTy>::value_type *)) {
1103 auto NElts = End - Start;
1104 if (NElts <= 1)
return;
1105 #ifdef EXPENSIVE_CHECKS 1106 std::mt19937 Generator(std::random_device{}());
1107 std::shuffle(Start, End, Generator);
1109 qsort(&*Start, NElts,
sizeof(*Start),
1110 reinterpret_cast<int (*)(
const void *,
const void *)
>(
Compare));
1115 template <
typename IteratorTy>
1116 inline void sort(IteratorTy Start, IteratorTy End) {
1117 #ifdef EXPENSIVE_CHECKS 1118 std::mt19937 Generator(std::random_device{}());
1119 std::shuffle(Start, End, Generator);
1124 template <
typename Container>
inline void sort(Container &&
C) {
1128 template <
typename IteratorTy,
typename Compare>
1130 #ifdef EXPENSIVE_CHECKS 1131 std::mt19937 Generator(std::random_device{}());
1132 std::shuffle(Start, End, Generator);
1137 template <
typename Container,
typename Compare>
1148 template<
typename Container>
1157 template<
typename Container>
1166 template <
typename R>
1167 auto size(R &&Range,
typename std::enable_if<
1168 std::is_same<
typename std::iterator_traits<decltype(
1169 Range.begin())>::iterator_category,
1170 std::random_access_iterator_tag>::value,
1171 void>::
type * =
nullptr)
1172 -> decltype(std::distance(Range.begin(), Range.end())) {
1173 return std::distance(Range.begin(), Range.end());
1178 template <
typename R,
typename UnaryPredicate>
1185 template <
typename R,
typename UnaryPredicate>
1192 template <
typename R,
typename UnaryPredicate>
1199 template <
typename R,
typename UnaryPredicate>
1206 template <
typename R,
typename T>
1213 template <
typename R,
typename UnaryPredicate>
1218 template <
typename R,
typename UnaryPredicate>
1225 template <
typename R,
typename UnaryPredicate>
1232 template <
typename R,
typename OutputIt,
typename UnaryPredicate>
1233 OutputIt
copy_if(R &&Range, OutputIt Out, UnaryPredicate
P) {
1237 template <
typename R,
typename OutputIt>
1238 OutputIt
copy(R &&Range, OutputIt Out) {
1244 template <
typename R,
typename E>
1251 template <
typename R,
typename E>
1253 typename std::iterator_traits<decltype(adl_begin(Range))>::difference_type {
1259 template <
typename R,
typename UnaryPredicate>
1261 typename std::iterator_traits<decltype(adl_begin(Range))>::difference_type {
1267 template <
typename R,
typename OutputIt,
typename UnaryPredicate>
1268 OutputIt
transform(R &&Range, OutputIt d_first, UnaryPredicate
P) {
1274 template <
typename R,
typename UnaryPredicate>
1281 template <
typename R,
typename ForwardIt>
1286 template <
typename R,
typename ForwardIt,
typename Compare>
1294 template <
typename R,
typename ForwardIt>
1299 template <
typename R,
typename ForwardIt,
typename Compare>
1306 template <
typename R>
1308 size_t range_size =
size(Range);
1309 return range_size != 0 && (range_size == 1 ||
1316 template <
unsigned Size,
typename R>
1329 template <
typename Container,
typename UnaryPredicate>
1347 template <
class T,
class...
Args>
1348 typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
1350 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
1362 typename std::enable_if<std::is_array<T>::value && std::extent<T>::value == 0,
1363 std::unique_ptr<T>>::type
1365 return std::unique_ptr<T>(
new typename std::remove_extent<T>::type[n]());
1369 template <
class T,
class...
Args>
1370 typename std::enable_if<std::extent<T>::value != 0>::type
1379 template<
typename First,
typename Second>
1382 return std::hash<First>()(P.first) * 31 + std::hash<Second>()(P.second);
1388 template <
typename A,
typename B>
bool operator()(A &&a,
B &&b)
const {
1389 return std::forward<A>(a) < std::forward<B>(b);
1395 template <
typename A,
typename B>
bool operator()(A &&a,
B &&b)
const {
1396 return std::forward<A>(a) == std::forward<B>(b);
1408 template <
typename A,
typename B>
1412 return func(*lhs, *rhs);
1425 : Index(Index), Iter(Iter) {}
1428 Index = Other.Index;
1442 template <
typename R>
1445 enumerator_iter<R>, std::forward_iterator_tag, result_pair<R>,
1446 typename std::iterator_traits<IterOfRange<R>>::difference_type,
1447 typename std::iterator_traits<IterOfRange<R>>::pointer,
1448 typename std::iterator_traits<IterOfRange<R>>::reference> {
1453 : Result(
std::numeric_limits<
size_t>::
max(), EndIter) {}
1456 : Result(Index, Iter) {}
1472 return Result.Iter == RHS.Result.Iter;
1476 Result = Other.Result;
1523 template <
typename F,
typename Tuple, std::size_t... I>
1525 -> decltype(std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...)) {
1526 return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
1534 template <
typename F,
typename Tuple>
1536 std::forward<F>(f), std::forward<Tuple>(t),
1538 std::tuple_size<
typename std::decay<Tuple>::type>::value>{})) {
1540 std::tuple_size<typename std::decay<Tuple>::type>::value>;
1548 template <
typename IterTy>
1550 IterTy &&Begin, IterTy &&End,
unsigned N,
1551 typename std::enable_if<
1553 typename std::iterator_traits<
typename std::remove_reference<
1554 decltype(Begin)>::
type>::iterator_category,
1555 std::random_access_iterator_tag>::value,
1556 void>::
type * =
nullptr) {
1557 for (;
N; --
N, ++Begin)
1560 return Begin == End;
1565 template <
typename IterTy>
1567 IterTy &&Begin, IterTy &&End,
unsigned N,
1568 typename std::enable_if<
1570 typename std::iterator_traits<
typename std::remove_reference<
1571 decltype(Begin)>::
type>::iterator_category,
1572 std::random_access_iterator_tag>::value,
1573 void>::
type * =
nullptr) {
1574 for (;
N; --
N, ++Begin)
1582 #endif // LLVM_ADT_STLEXTRAS_H detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&... Ranges)
Concatenated range across two or more ranges.
result_pair(std::size_t Index, IterOfRange< R > Iter)
void DeleteContainerSeconds(Container &C)
In a container of pairs (usually a map) whose second element is a pointer, deletes the second element...
void DeleteContainerPointers(Container &C)
For a container of pointers, deletes the pointers and then clears the container.
bool operator()(const Ty *left, const Ty *right) const
typename iterator::pointer pointer
bool operator==(const enumerator_iter< R > &RHS) const
const_iterator end(StringRef path)
Get end iterator over path.
bool operator==(const zip_longest_iterator< Iters... > &other) const
filter_iterator_impl(WrappedIteratorT Begin, WrappedIteratorT End, PredicateT Pred)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Ret operator()(Params ...params) const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
bool operator()(const T &lhs, const T &rhs) const
typename fwd_or_bidi_tag_impl< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< IterT >::iterator_category >::value >::type type
This class represents lattice values for constants.
typename Base::value_type value_type
A pseudo-iterator adaptor that is designed to implement "early increment" style loops.
typename std::remove_reference< decltype(*std::begin(std::declval< RangeT & >()))>::type ValueOfRange
decltype(iterators) tup_inc(index_sequence< Ns... >) const
Function object to check whether the second component of a std::pair compares less than the second co...
OutputIt copy_if(R &&Range, OutputIt Out, UnaryPredicate P)
Provide wrappers to std::copy_if which take ranges instead of having to pass begin/end explicitly...
typename iterator::value_type value_type
const Ty & operator()(const Ty &self) const
result_type & operator*()
detail::zip_longest_range< T, U, Args... > zip_longest(T &&t, U &&u, Args &&... args)
Iterate over two or more iterators at the same time.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
filter_iterator_base(WrappedIteratorT Begin, WrappedIteratorT End, PredicateT Pred)
zip_longest_iterator(std::pair< Iters &&, Iters &&>... ts)
int(*)(const void *, const void *) get_array_pod_sort_comparator(const T &)
get_array_pod_sort_comparator - This is an internal helper function used to get type deduction of T r...
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
auto operator()(const T &lhs, const T &rhs) const -> decltype(func(lhs.first, rhs.first))
bool operator()(const T &lhs, const T &rhs) const
An efficient, type-erasing, non-owning reference to a callable.
A functor like C++14's std::less<void> in its absence.
zip_common(Iters &&... ts)
void adl_swap(T &&lhs, T &&rhs) noexcept(noexcept(adl_detail::adl_swap(std::declval< T >(), std::declval< T >())))
enumerator_iter(IterOfRange< R > EndIter)
auto count_if(R &&Range, UnaryPredicate P) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
early_inc_iterator_impl(WrappedIteratorT I)
block Block Frequency true
std::tuple< decltype(*declval< Iters >())... > type
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&... args)
Constructs a new T() with the given args and returns a unique_ptr<T> which owns the object...
BaseT::reference operator*()
typename iterator::difference_type difference_type
typename iterator::pointer pointer
int array_pod_sort_comparator(const void *P1, const void *P2)
Adapt std::less<T> for array_pod_sort.
void adl_swap(T &&lhs, T &&rhs) noexcept(noexcept(swap(std::declval< T >(), std::declval< T >())))
zip_longest_range(Args &&... ts_)
Metafunction to determine if T& or T has a member called rbegin().
function_ref(Callable &&callable, typename std::enable_if< !std::is_same< typename std::remove_reference< Callable >::type, function_ref >::value >::type *=nullptr)
Ty & operator()(Ty &self) const
void sort(Container &&C, Compare Comp)
concat_range(RangeTs &&... Ranges)
std::bidirectional_iterator_tag type
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
decltype(iterators) tup_dec(index_sequence< Ns... >) const
auto upper_bound(R &&Range, ForwardIt I, Compare C) -> decltype(adl_begin(Range))
typename std::add_pointer< typename std::add_const< T >::type >::type type
SmallVector< typename std::remove_const< detail::ValueOfRange< R > >::type, Size > to_vector(R &&Range)
Given a range of type R, iterate the entire range and return a SmallVector with elements of the vecto...
Alias for the common case of a sequence of size_ts.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
bool operator()(const Ty *left, const Ty *right) const
filter_iterator_impl & operator--()
enumerator_iter< R > & operator++()
auto apply_tuple(F &&f, Tuple &&t) -> decltype(detail::apply_tuple_impl(std::forward< F >(f), std::forward< Tuple >(t), build_index_impl< std::tuple_size< typename std::decay< Tuple >::type >::value >
Given an input tuple (a1, a2, ..., an), pass the arguments of the tuple variadically to f as if by ca...
auto partition(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly...
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
enumerator_iter(std::size_t Index, IterOfRange< R > Iter)
Helper to store a sequence of ranges being concatenated and access them.
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
traits class for checking whether type T is one of any of the given types in the variadic list...
ValueOfRange< R > & value()
typename iterator::reference reference
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
auto operator()(A &lhs, B &rhs) const -> decltype(func(*lhs, *rhs))
auto adl_end(ContainerTy &&container) -> decltype(end(std::forward< ContainerTy >(container)))
bool operator==(const early_inc_iterator_impl &RHS) const
bool is_splat(R &&Range)
Wrapper function around std::equal to detect if all elements in a container are same.
CRTP base class for adapting an iterator to a different type.
mapped_iterator(ItTy U, FuncTy F)
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&... args)
zip iterator for two or more iteratable types.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const result_type & operator*() const
mapped_iterator< ItTy, FuncTy > map_iterator(ItTy I, FuncTy F)
auto adl_begin(ContainerTy &&container) -> decltype(adl_detail::adl_begin(std::forward< ContainerTy >(container)))
filter_iterator_impl(WrappedIteratorT Begin, WrappedIteratorT End, PredicateT Pred)
value_type operator*() const
Helper to determine if type T has a member called rbegin().
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
bool hasNItemsOrMore(IterTy &&Begin, IterTy &&End, unsigned N, typename std::enable_if< !std::is_same< typename std::iterator_traits< typename std::remove_reference< decltype(Begin)>::type >::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr)
Return true if the sequence [Begin, End) has N or more items.
auto find_if_not(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
detail::zippy< detail::zip_first, T, U, Args... > zip_first(T &&t, U &&u, Args &&... args)
zip iterator that, for the sake of efficiency, assumes the first iteratee to be the shortest...
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
static auto deref_or_none(const Iter &I, const Iter &End) -> llvm::Optional< typename std::remove_const< typename std::remove_reference< decltype(*I)>::type >::type >
zip_longest_iterator< Iters... > & operator++()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static constexpr size_t size()
void sort(IteratorTy Start, IteratorTy End)
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
bool operator()(A &&a, B &&b) const
auto apply_tuple_impl(F &&f, Tuple &&t, index_sequence< I... >) -> decltype(std::forward< F >(f)(std::get< I >(std::forward< Tuple >(t))...))
A functor like C++14's std::equal<void> in its absence.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
value_type deref(index_sequence< Ns... >) const
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
static Iter next_or_end(const Iter &I, const Iter &End)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
typename iterator::reference reference
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
An iterator adaptor that filters the elements of given inner iterators.
Creates a compile-time integer sequence for a parameter pack.
auto adl_begin(ContainerTy &&container) -> decltype(begin(std::forward< ContainerTy >(container)))
typename iterator::difference_type difference_type
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A range adaptor for a pair of iterators.
bool operator()(A &&a, B &&b) const
std::forward_iterator_tag type
Represents a compile-time sequence of integers.
filter_iterator_base & operator++()
Helper which sets its type member to forward_iterator_tag if the category of IterT does not derive fr...
enumerator_iter< R > & operator=(const enumerator_iter< R > &Other)
concat_iterator & operator++()
auto lower_bound(R &&Range, ForwardIt I, Compare C) -> decltype(adl_begin(Range))
result_pair< R > & operator=(const result_pair< R > &Other)
ValueT & operator*() const
bool operator==(const zip_first< Iters... > &other) const
typename ZipLongestTupleType< Iters... >::type value_type
bool operator==(const concat_iterator &RHS) const
typename iterator::iterator_category iterator_category
typename iterator::value_type value_type
function_ref(std::nullptr_t)
decltype(std::begin(std::declval< RangeT & >())) IterOfRange
const ValueOfRange< R > & value() const
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...
std::tuple< Iters... > iterators
OutputIt transform(R &&Range, OutputIt d_first, UnaryPredicate P)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere...
const value_type operator*() const
auto upper_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
auto adl_end(ContainerTy &&container) -> decltype(adl_detail::adl_end(std::forward< ContainerTy >(container)))
typename std::add_lvalue_reference< typename std::add_const< T >::type >::type type
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::reverse_iterator< IteratorTy > make_reverse_iterator(IteratorTy It)
traits class for checking whether type T is a base class for all the given types in the variadic list...
std::tuple< typename ZipLongestItemType< Iters >::type... > type
enumerator_iter< R > begin()
early_inc_iterator_impl & operator++()
Function object to apply a binary function to the first component of a std::pair. ...
bool hasNItems(IterTy &&Begin, IterTy &&End, unsigned N, typename std::enable_if< !std::is_same< typename std::iterator_traits< typename std::remove_reference< decltype(Begin)>::type >::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr)
Return true if the sequence [Begin, End) has exactly N items.
enumerator_iter< R > end()
Specialization of filter_iterator_base for forward iteration only.
bool operator==(uint64_t V1, const APInt &V2)
Binary functor that adapts to any other binary functor after dereferencing operands.
Iterator wrapper that concatenates sequences together.
Utility type to build an inheritance chain that makes it easy to rank overload candidates.
zip_shortest(Iters &&... ts)
UnaryPredicate for_each(R &&Range, UnaryPredicate P)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly...
OutputIt copy(R &&Range, OutputIt Out)
zip_first(Iters &&... ts)
std::size_t index() const
Function object to check whether the first component of a std::pair compares less than the first comp...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
concat_iterator(RangeTs &&... Ranges)
Constructs an iterator from a squence of ranges.
bool operator==(const zip_shortest< Iters... > &other) const
detail::enumerator< R > enumerate(R &&TheRange)
Given an input range, returns a new range whose values are are pair (A,B) such that A is the 0-based ...
typename iterator::iterator_category iterator_category
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
size_t operator()(const std::pair< First, Second > &P) const