16 #ifndef LLVM_ADT_STLEXTRAS_H 17 #define LLVM_ADT_STLEXTRAS_H 22 #include "llvm/Config/abi-breaking.h" 30 #include <initializer_list> 35 #include <type_traits> 38 #ifdef EXPENSIVE_CHECKS 50 template <
typename RangeT>
60 struct negation : std::integral_constant<bool, !bool(T::value)> {};
62 template <
typename...>
struct conjunction : std::true_type {};
64 template <
typename B1,
typename... Bn>
66 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>
::type {};
70 typename std::add_pointer<typename std::add_const<T>::type>
::type;
74 using type =
typename std::add_lvalue_reference<
75 typename std::add_const<T>::type>
::type;
101 template<
typename Ret,
typename ...Params>
106 template<
typename Callable>
107 static Ret callback_fn(
intptr_t callable, Params ...params) {
108 return (*reinterpret_cast<Callable*>(callable))(
109 std::forward<Params>(params)...);
116 template <
typename Callable>
118 typename std::enable_if<
119 !std::is_same<
typename std::remove_reference<Callable>::type,
121 :
callback(callback_fn<typename
std::remove_reference<Callable>::
type>),
122 callable(reinterpret_cast<
intptr_t>(&callable)) {}
125 return callback(callable, std::forward<Params>(params)...);
144 namespace adl_detail {
148 template <
typename ContainerTy>
150 -> decltype(
begin(std::forward<ContainerTy>(container))) {
151 return begin(std::forward<ContainerTy>(container));
156 template <
typename ContainerTy>
158 -> decltype(
end(std::forward<ContainerTy>(container))) {
159 return end(std::forward<ContainerTy>(container));
164 template <
typename T>
166 std::declval<T>()))) {
167 swap(std::forward<T>(lhs), std::forward<T>(rhs));
172 template <
typename ContainerTy>
178 template <
typename ContainerTy>
184 template <
typename T>
191 template <
typename T>
192 constexpr
bool empty(
const T &RangeOrContainer) {
198 template <
typename T>
208 template <
typename ItTy,
typename FuncTy,
209 typename FuncReturnTy =
210 decltype(std::declval<FuncTy>()(*std::declval<ItTy>()))>
213 mapped_iterator<ItTy, FuncTy>, ItTy,
214 typename std::iterator_traits<ItTy>::iterator_category,
215 typename std::remove_reference<FuncReturnTy>::type> {
230 template <
class ItTy,
class FuncTy>
235 template <
class ContainerTy,
class FuncTy>
247 template <
typename Inner>
248 static yes&
test(Inner *
I, decltype(I->rbegin()) * =
nullptr);
251 static no&
test(...);
254 static const bool value =
sizeof(test<Ty>(
nullptr)) ==
sizeof(yes);
258 template <
typename Ty>
264 template <
typename ContainerTy>
267 nullptr) -> decltype(
make_range(
C.rbegin(),
C.rend())) {
272 template <
typename IteratorTy>
274 return std::reverse_iterator<IteratorTy>(It);
280 template <
typename ContainerTy>
306 template <
typename WrappedIteratorT,
typename PredicateT,
typename IterTag>
309 filter_iterator_base<WrappedIteratorT, PredicateT, IterTag>,
311 typename std::common_type<
312 IterTag, typename std::iterator_traits<
313 WrappedIteratorT>::iterator_category>::type> {
317 typename std::common_type<
318 IterTag,
typename std::iterator_traits<
319 WrappedIteratorT>::iterator_category>
::type>;
326 while (this->
I != End && !Pred(*this->
I))
335 : BaseT(Begin), End(End), Pred(Pred) {
340 using BaseT::operator++;
350 template <
typename WrappedIteratorT,
typename PredicateT,
351 typename IterTag = std::forward_iterator_tag>
359 :
BaseT(Begin, End, Pred) {}
363 template <
typename WrappedIteratorT,
typename PredicateT>
365 std::bidirectional_iterator_tag>
367 std::bidirectional_iterator_tag> {
369 std::bidirectional_iterator_tag>;
370 void findPrevValid() {
371 while (!this->Pred(*this->
I))
376 using BaseT::operator--;
380 : BaseT(Begin, End, Pred) {}
392 using type = std::forward_iterator_tag;
396 using type = std::bidirectional_iterator_tag;
404 std::bidirectional_iterator_tag,
405 typename std::iterator_traits<IterT>::iterator_category>::value>
::type;
412 template <
typename WrappedIteratorT,
typename PredicateT>
414 WrappedIteratorT, PredicateT,
424 template <
typename RangeT,
typename PredicateT>
427 using FilterIteratorT =
430 FilterIteratorT(
std::begin(std::forward<RangeT>(Range)),
431 std::end(std::forward<RangeT>(Range)), Pred),
432 FilterIteratorT(
std::end(std::forward<RangeT>(Range)),
433 std::end(std::forward<RangeT>(Range)), Pred));
453 template <
typename WrappedIteratorT>
456 WrappedIteratorT, std::input_iterator_tag> {
459 WrappedIteratorT, std::input_iterator_tag>;
461 using PointerT =
typename std::iterator_traits<WrappedIteratorT>::pointer;
464 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 465 bool IsEarlyIncremented =
false;
471 using BaseT::operator*;
473 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 474 assert(!IsEarlyIncremented &&
"Cannot dereference twice!");
475 IsEarlyIncremented =
true;
480 using BaseT::operator++;
482 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 483 assert(IsEarlyIncremented &&
"Cannot increment before dereferencing!");
484 IsEarlyIncremented =
false;
489 using BaseT::operator==;
491 #if LLVM_ENABLE_ABI_BREAKING_CHECKS 492 assert(!IsEarlyIncremented &&
"Cannot compare after dereferencing!");
510 template <
typename RangeT>
513 using EarlyIncIteratorT =
516 EarlyIncIteratorT(
std::end(std::forward<RangeT>(Range))));
520 template <
typename R,
typename UnaryPredicate>
521 bool all_of(R &&range, UnaryPredicate
P);
522 template <
typename R,
typename UnaryPredicate>
523 bool any_of(R &&range, UnaryPredicate P);
532 using type = std::tuple<decltype(*declval<Iters>())...>;
535 template <
typename ZipType,
typename... Iters>
537 ZipType,
typename std::common_type<std::bidirectional_iterator_tag,
538 typename std::iterator_traits<
539 Iters>::iterator_category...>
::type,
542 typename std::iterator_traits<
typename std::tuple_element<
543 0, std::tuple<Iters...>>
::type>::difference_type,
551 template <
typename ZipType,
typename... Iters>
553 using Base = zip_traits<ZipType, Iters...>;
560 return value_type(*std::get<Ns>(iterators)...);
563 template <
size_t... Ns>
564 decltype(iterators)
tup_inc(std::index_sequence<Ns...>)
const {
565 return std::tuple<Iters...>(std::next(std::get<Ns>(iterators))...);
568 template <
size_t... Ns>
569 decltype(iterators)
tup_dec(std::index_sequence<Ns...>)
const {
570 return std::tuple<Iters...>(std::prev(std::get<Ns>(iterators))...);
579 return deref(std::index_sequence_for<Iters...>{});
583 iterators = tup_inc(std::index_sequence_for<Iters...>{});
584 return *
reinterpret_cast<ZipType *
>(
this);
588 static_assert(Base::IsBidirectional,
589 "All inner iterators must be at least bidirectional.");
590 iterators = tup_dec(std::index_sequence_for<Iters...>{});
591 return *
reinterpret_cast<ZipType *
>(
this);
595 template <
typename... Iters>
600 return std::get<0>(this->iterators) == std::get<0>(other.
iterators);
606 template <
typename... Iters>
608 template <
size_t... Ns>
610 std::index_sequence<Ns...>)
const {
611 return all_of(std::initializer_list<bool>{std::get<Ns>(this->iterators) !=
622 return !
test(other, std::index_sequence_for<Iters...>{});
636 std::tuple<
Args...> ts;
638 template <
size_t... Ns>
639 iterator begin_impl(std::index_sequence<Ns...>)
const {
642 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>)
const {
650 return begin_impl(std::index_sequence_for<Args...>{});
652 iterator end()
const {
return end_impl(std::index_sequence_for<Args...>{}); }
658 template <
typename T,
typename U,
typename...
Args>
662 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(args)...);
667 template <
typename T,
typename U,
typename...
Args>
671 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(args)...);
675 template <
typename Iter>
682 template <
typename Iter>
685 typename std::remove_reference<decltype(*I)>::type>
::type> {
693 llvm::Optional<
typename std::remove_const<
typename std::remove_reference<
698 using type = std::tuple<typename ZipLongestItemType<Iters>::type...>;
701 template <
typename... Iters>
704 zip_longest_iterator<Iters...>,
705 typename std::common_type<
706 std::forward_iterator_tag,
707 typename std::iterator_traits<Iters>::iterator_category...>::type,
708 typename ZipLongestTupleType<Iters...>::type,
709 typename std::iterator_traits<typename std::tuple_element<
710 0, std::tuple<Iters...>>::type>::difference_type,
711 typename ZipLongestTupleType<Iters...>::type *,
712 typename ZipLongestTupleType<Iters...>::type> {
717 std::tuple<Iters...> iterators;
718 std::tuple<Iters...> end_iterators;
720 template <
size_t... Ns>
722 std::index_sequence<Ns...>)
const {
724 std::initializer_list<bool>{std::get<Ns>(this->iterators) !=
725 std::get<Ns>(other.iterators)...},
729 template <
size_t... Ns>
value_type deref(std::index_sequence<Ns...>)
const {
731 deref_or_none(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
734 template <
size_t... Ns>
735 decltype(iterators) tup_inc(std::index_sequence<Ns...>)
const {
736 return std::tuple<Iters...>(
737 next_or_end(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
742 : iterators(
std::forward<Iters>(ts.
first)...),
743 end_iterators(
std::forward<Iters>(ts.
second)...) {}
748 return deref(std::index_sequence_for<Iters...>{});
752 iterators = tup_inc(std::index_sequence_for<Iters...>{});
757 return !
test(other, std::index_sequence_for<Iters...>{});
772 std::tuple<
Args...> ts;
774 template <
size_t... Ns>
775 iterator begin_impl(std::index_sequence<Ns...>)
const {
777 adl_end(std::get<Ns>(ts)))...);
780 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>)
const {
782 adl_end(std::get<Ns>(ts)))...);
789 return begin_impl(std::index_sequence_for<Args...>{});
791 iterator end()
const {
return end_impl(std::index_sequence_for<Args...>{}); }
798 template <
typename T,
typename U,
typename...
Args>
802 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(args)...);
815 template <
typename ValueT,
typename... IterTs>
818 std::forward_iterator_tag, ValueT> {
819 using BaseT =
typename concat_iterator::iterator_facade_base;
827 std::tuple<IterTs...> Begins;
828 std::tuple<IterTs...> Ends;
834 template <
size_t Index>
bool incrementHelper() {
835 auto &Begin = std::get<Index>(Begins);
836 auto &End = std::get<Index>(Ends);
847 template <
size_t... Ns>
void increment(std::index_sequence<Ns...>) {
850 &concat_iterator::incrementHelper<Ns>...};
853 for (
auto &IncrementHelperFn : IncrementHelperFns)
854 if ((this->*IncrementHelperFn)())
863 template <
size_t Index>
ValueT *getHelper()
const {
864 auto &Begin = std::get<Index>(Begins);
865 auto &End = std::get<Index>(Ends);
876 template <
size_t... Ns>
ValueT &
get(std::index_sequence<Ns...>)
const {
879 &concat_iterator::getHelper<Ns>...};
882 for (
auto &GetHelperFn : GetHelperFns)
883 if (
ValueT *
P = (this->*GetHelperFn)())
886 llvm_unreachable(
"Attempted to get a pointer from an end concat iterator!");
894 template <
typename... RangeTs>
898 using BaseT::operator++;
901 increment(std::index_sequence_for<IterTs...>());
906 return get(std::index_sequence_for<IterTs...>());
910 return Begins == RHS.Begins && Ends == RHS.Ends;
928 std::tuple<RangeTs...> Ranges;
930 template <
size_t... Ns>
iterator begin_impl(std::index_sequence<Ns...>) {
931 return iterator(std::get<Ns>(Ranges)...);
933 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>) {
935 std::end(std::get<Ns>(Ranges)))...);
940 : Ranges(
std::forward<RangeTs>(Ranges)...) {}
942 iterator begin() {
return begin_impl(std::index_sequence_for<RangeTs...>{}); }
943 iterator end() {
return end_impl(std::index_sequence_for<RangeTs...>{}); }
951 template <
typename ValueT,
typename... RangeTs>
953 static_assert(
sizeof...(RangeTs) > 1,
954 "Need more than one range to concatenate!");
956 std::forward<RangeTs>(Ranges)...);
966 template <
typename T>
bool operator()(
const T &lhs,
const T &rhs)
const {
967 return lhs.first < rhs.first;
974 template <
typename T>
bool operator()(
const T &lhs,
const T &rhs)
const {
975 return lhs.second < rhs.second;
981 template<
typename FuncTy>
985 template <
typename T>
987 -> decltype(func(lhs.first, rhs.first)) {
988 return func(lhs.first, rhs.first);
1000 static const bool value =
false;
1003 template <
typename T,
typename U,
typename... Ts>
1005 static const bool value =
1006 std::is_same<T, U>::value ||
is_one_of<
T, Ts...>::value;
1012 static const bool value =
true;
1015 template <
typename T,
typename U,
typename... Ts>
1017 static const bool value =
1018 std::is_base_of<T, U>::value &&
are_base_of<
T, Ts...>::value;
1026 template <
class T, std::
size_t N>
1032 template<
typename T>
1034 if (std::less<T>()(*reinterpret_cast<const T*>(P1),
1035 *reinterpret_cast<const T*>(P2)))
1037 if (std::less<T>()(*reinterpret_cast<const T*>(P2),
1038 *reinterpret_cast<const T*>(P1)))
1045 template<
typename T>
1047 (
const void*,
const void*) {
1048 return array_pod_sort_comparator<T>;
1051 #ifdef EXPENSIVE_CHECKS 1054 inline unsigned presortShuffleEntropy() {
1055 static unsigned Result(std::random_device{}());
1059 template <
class IteratorTy>
1060 inline void presortShuffle(IteratorTy Start, IteratorTy End) {
1061 std::mt19937 Generator(presortShuffleEntropy());
1062 std::shuffle(Start, End, Generator);
1082 template<
class IteratorTy>
1086 auto NElts = End - Start;
1087 if (NElts <= 1)
return;
1088 #ifdef EXPENSIVE_CHECKS 1089 detail::presortShuffle<IteratorTy>(Start, End);
1094 template <
class IteratorTy>
1096 IteratorTy Start, IteratorTy End,
1098 const typename std::iterator_traits<IteratorTy>::value_type *,
1099 const typename std::iterator_traits<IteratorTy>::value_type *)) {
1102 auto NElts = End - Start;
1103 if (NElts <= 1)
return;
1104 #ifdef EXPENSIVE_CHECKS 1105 detail::presortShuffle<IteratorTy>(Start, End);
1107 qsort(&*Start, NElts,
sizeof(*Start),
1108 reinterpret_cast<int (*)(
const void *,
const void *)
>(
Compare));
1113 template <
typename IteratorTy>
1114 inline void sort(IteratorTy Start, IteratorTy End) {
1115 #ifdef EXPENSIVE_CHECKS 1116 detail::presortShuffle<IteratorTy>(Start, End);
1121 template <
typename Container>
inline void sort(Container &&
C) {
1125 template <
typename IteratorTy,
typename Compare>
1127 #ifdef EXPENSIVE_CHECKS 1128 detail::presortShuffle<IteratorTy>(Start, End);
1133 template <
typename Container,
typename Compare>
1144 template<
typename Container>
1153 template<
typename Container>
1162 template <
typename R>
1163 auto size(R &&Range,
typename std::enable_if<
1164 std::is_same<
typename std::iterator_traits<decltype(
1165 Range.begin())>::iterator_category,
1166 std::random_access_iterator_tag>::value,
1167 void>::
type * =
nullptr)
1168 -> decltype(std::distance(Range.begin(), Range.end())) {
1169 return std::distance(Range.begin(), Range.end());
1174 template <
typename R,
typename UnaryPredicate>
1181 template <
typename R,
typename UnaryPredicate>
1188 template <
typename R,
typename UnaryPredicate>
1195 template <
typename R,
typename UnaryPredicate>
1202 template <
typename R,
typename T>
1209 template <
typename R,
typename UnaryPredicate>
1214 template <
typename R,
typename UnaryPredicate>
1221 template <
typename R,
typename UnaryPredicate>
1228 template <
typename R,
typename OutputIt,
typename UnaryPredicate>
1229 OutputIt
copy_if(R &&Range, OutputIt Out, UnaryPredicate
P) {
1233 template <
typename R,
typename OutputIt>
1234 OutputIt
copy(R &&Range, OutputIt Out) {
1240 template <
typename R,
typename E>
1247 template <
typename R,
typename E>
1249 typename std::iterator_traits<decltype(adl_begin(Range))>::difference_type {
1255 template <
typename R,
typename UnaryPredicate>
1257 typename std::iterator_traits<decltype(adl_begin(Range))>::difference_type {
1263 template <
typename R,
typename OutputIt,
typename UnaryPredicate>
1264 OutputIt
transform(R &&Range, OutputIt d_first, UnaryPredicate
P) {
1270 template <
typename R,
typename UnaryPredicate>
1277 template <
typename R,
typename T>
1280 std::forward<T>(
Value));
1283 template <
typename R,
typename T,
typename Compare>
1287 std::forward<T>(
Value),
C);
1292 template <
typename R,
typename T>
1295 std::forward<T>(
Value));
1298 template <
typename R,
typename T,
typename Compare>
1302 std::forward<T>(
Value),
C);
1305 template <
typename R>
1310 template <
typename R,
typename Compare>
1317 template <
typename R,
typename Predicate,
1318 typename Val = decltype(*
adl_begin(std::declval<R>()))>
1325 template <
typename R>
1327 size_t range_size =
size(Range);
1328 return range_size != 0 && (range_size == 1 ||
1339 template <
typename Container,
typename UnaryPredicate>
1346 template<
typename Container,
typename RandomAccessIterator>
1347 void replace(Container &Cont,
typename Container::iterator ContIt,
1348 typename Container::iterator ContEnd, RandomAccessIterator ValIt,
1349 RandomAccessIterator ValEnd) {
1351 if (ValIt == ValEnd) {
1352 Cont.erase(ContIt, ContEnd);
1354 }
else if (ContIt == ContEnd) {
1355 Cont.insert(ContIt, ValIt, ValEnd);
1358 *ContIt++ = *ValIt++;
1364 template<
typename Container,
typename Range = std::initializer_list<
1365 typename Container::value_type>>
1366 void replace(Container &Cont,
typename Container::iterator ContIt,
1367 typename Container::iterator ContEnd, Range R) {
1368 replace(Cont, ContIt, ContEnd, R.begin(), R.end());
1381 template<
typename First,
typename Second>
1384 return std::hash<First>()(P.first) * 31 + std::hash<Second>()(P.second);
1396 template <
typename A,
typename B>
1400 return func(*lhs, *rhs);
1410 typename std::iterator_traits<IterOfRange<R>>::reference;
1416 : Index(Index), Iter(Iter) {}
1421 Index = Other.Index;
1435 template <
typename R>
1438 enumerator_iter<R>, std::forward_iterator_tag, result_pair<R>,
1439 typename std::iterator_traits<IterOfRange<R>>::difference_type,
1440 typename std::iterator_traits<IterOfRange<R>>::pointer,
1441 typename std::iterator_traits<IterOfRange<R>>::reference> {
1446 : Result(
std::numeric_limits<
size_t>::
max(), EndIter) {}
1449 : Result(Index, Iter) {}
1465 return Result.Iter == RHS.Result.Iter;
1470 Result = Other.Result;
1517 template <
typename F,
typename Tuple, std::size_t...
I>
1519 -> decltype(std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...)) {
1520 return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
1528 template <
typename F,
typename Tuple>
1530 std::forward<F>(f), std::forward<Tuple>(t),
1531 std::make_index_sequence<
1532 std::tuple_size<
typename std::decay<Tuple>::type>::value>{})) {
1533 using Indices = std::make_index_sequence<
1534 std::tuple_size<typename std::decay<Tuple>::type>::value>;
1542 template <
typename IterTy>
1544 IterTy &&Begin, IterTy &&End,
unsigned N,
1545 typename std::enable_if<
1547 typename std::iterator_traits<
typename std::remove_reference<
1548 decltype(Begin)>::
type>::iterator_category,
1549 std::random_access_iterator_tag>::value,
1550 void>::
type * =
nullptr) {
1551 for (;
N; --
N, ++Begin)
1554 return Begin == End;
1559 template <
typename IterTy>
1561 IterTy &&Begin, IterTy &&End,
unsigned N,
1562 typename std::enable_if<
1564 typename std::iterator_traits<
typename std::remove_reference<
1565 decltype(Begin)>::
type>::iterator_category,
1566 std::random_access_iterator_tag>::value,
1567 void>::
type * =
nullptr) {
1568 for (;
N; --
N, ++Begin)
1582 template <
class Ptr>
auto to_address(
const Ptr &
P) -> decltype(
P.operator->()) {
1583 return P.operator->();
1589 #endif // LLVM_ADT_STLEXTRAS_H detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&... Ranges)
Concatenated range across two or more ranges.
auto lower_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
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.
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
auto drop_begin(T &&RangeOrContainer, size_t N) -> iterator_range< decltype(adl_begin(RangeOrContainer))>
Return a range covering RangeOrContainer with the first N elements excluded.
filter_iterator_impl(WrappedIteratorT Begin, WrappedIteratorT End, PredicateT Pred)
const value_reference value() const
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.
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)
auto apply_tuple_impl(F &&f, Tuple &&t, std::index_sequence< I... >) -> decltype(std::forward< F >(f)(std::get< I >(std::forward< Tuple >(t))...))
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...
void replace(Container &Cont, typename Container::iterator ContIt, typename Container::iterator ContEnd, RandomAccessIterator ValIt, RandomAccessIterator ValEnd)
Given a sequence container Cont, replace the range [ContIt, ContEnd) with the range [ValIt...
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...
Optional< std::vector< StOtherPiece > > Other
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.
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...
auto to_address(const Ptr &P) -> decltype(P.operator->())
Returns a raw pointer that represents the same address as the argument.
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)
auto lower_bound(R &&Range, T &&Value, Compare C) -> decltype(adl_begin(Range))
block Block Frequency true
std::tuple< decltype(*declval< Iters >())... > type
BaseT::reference operator*()
typename iterator::difference_type difference_type
typename iterator::pointer pointer
typename std::iterator_traits< IterOfRange< R > >::reference value_reference
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...
typename std::add_pointer< typename std::add_const< T >::type >::type type
auto map_range(ContainerTy &&C, FuncTy F) -> decltype(make_range(map_iterator(C.begin(), F), map_iterator(C.end(), F)))
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
auto partition_point(R &&Range, Predicate P) -> decltype(adl_begin(Range))
Binary search for the first iterator in a range where a predicate is false.
filter_iterator_impl & operator--()
enumerator_iter< R > & operator++()
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 apply_tuple(F &&f, Tuple &&t) -> decltype(detail::apply_tuple_impl(std::forward< F >(f), std::forward< Tuple >(t), std::make_index_sequence< 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...
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...
typename iterator::reference reference
decltype(iterators) tup_dec(std::index_sequence< Ns... >) const
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...
decltype(iterators) tup_inc(std::index_sequence< Ns... >) const
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...
void stable_sort(R &&Range, Compare C)
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.
void sort(IteratorTy Start, IteratorTy End)
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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.
Align max(MaybeAlign Lhs, Align Rhs)
static Iter next_or_end(const Iter &I, const Iter &End)
auto upper_bound(R &&Range, T &&Value, Compare C) -> decltype(adl_begin(Range))
typename iterator::reference reference
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
An iterator adaptor that filters the elements of given inner iterators.
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.
std::forward_iterator_tag type
filter_iterator_base & operator++()
bool operator==(const StringView &LHS, const StringView &RHS)
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++()
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)
value_type deref(std::index_sequence< Ns... >) const
decltype(std::begin(std::declval< RangeT & >())) IterOfRange
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 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)
void stable_sort(R &&Range)
traits class for checking whether type T is a base class for all the given types in the variadic list...
LLVM Value Representation.
std::tuple< typename ZipLongestItemType< Iters >::type... > type
enumerator_iter< R > begin()
early_inc_iterator_impl & operator++()
cb< typename detail::callback_traits< F >::result_type, typename detail::callback_traits< F >::arg_type > callback(F CB)
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.
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 ...
auto upper_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range))
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
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