17#ifndef LLVM_ADT_STLEXTRAS_H
18#define LLVM_ADT_STLEXTRAS_H
26#include "llvm/Config/abi-breaking.h"
34#include <initializer_list>
43#ifdef EXPENSIVE_CHECKS
55template <
typename RangeT>
56using IterOfRange =
decltype(std::begin(std::declval<RangeT &>()));
58template <
typename RangeT>
60 std::remove_reference_t<decltype(*std::begin(std::declval<RangeT &>()))>;
69 using type = std::add_pointer_t<std::add_const_t<T>>;
73 using type = std::add_lvalue_reference_t<std::add_const_t<T>>;
77template <
class,
template <
class...>
class Op,
class... Args>
struct detector {
80template <
template <
class...>
class Op,
class... Args>
93template <
template <
class...>
class Op,
class... Args>
100template <typename T, bool isClass = std::is_class<T>::value>
104template <
typename ClassType,
typename ReturnType,
typename... Args>
107 enum { num_args =
sizeof...(Args) };
113 template <
size_t Index>
114 using arg_t = std::tuple_element_t<
Index, std::tuple<Args...>>;
117template <
typename ClassType,
typename ReturnType,
typename... Args>
121template <
typename ReturnType,
typename... Args>
124 enum { num_args =
sizeof...(Args) };
131 using arg_t = std::tuple_element_t<i, std::tuple<Args...>>;
133template <
typename ReturnType,
typename... Args>
137template <
typename ReturnType,
typename... Args>
143template <
typename T,
typename... Ts>
144using is_one_of = std::disjunction<std::is_same<T, Ts>...>;
148template <
typename T,
typename... Ts>
153template <
typename T,
typename... Us>
155 : std::integral_constant<bool, !is_one_of<T, Us...>::value &&
156 TypesAreDistinct<Us...>::value> {};
169template <
typename... Ts>
171 : std::integral_constant<bool, detail::TypesAreDistinct<Ts...>::value> {};
184template <
typename T,
typename U,
typename... Us>
186 : std::integral_constant<size_t, 1 + FirstIndexOfType<T, Us...>::value> {};
187template <
typename T,
typename... Us>
193template <
size_t I,
typename... Ts>
198template <
typename EnumTy1,
typename EnumTy2,
199 typename UT1 = std::enable_if_t<std::is_enum<EnumTy1>::value,
200 std::underlying_type_t<EnumTy1>>,
201 typename UT2 = std::enable_if_t<std::is_enum<EnumTy2>::value,
202 std::underlying_type_t<EnumTy2>>>
204 return static_cast<UT1
>(
LHS) +
static_cast<UT2
>(
RHS);
211namespace callable_detail {
224 bool = std::is_function_v<std::remove_pointer_t<remove_cvref_t<T>>>>
226 using value_type = std::remove_reference_t<T>;
227 using reference = value_type &;
228 using const_reference = value_type
const &;
230 std::optional<value_type> Obj;
232 static_assert(!std::is_pointer_v<value_type>,
233 "Pointers to non-functions are not callable.");
245 Obj.emplace(*
Other.Obj);
252 Obj.emplace(std::move(*
Other.Obj));
256 template <
typename... Pn,
257 std::enable_if_t<std::is_invocable_v<
T, Pn...>,
int> = 0>
258 decltype(
auto)
operator()(Pn &&...Params) {
259 return (*Obj)(std::forward<Pn>(Params)...);
262 template <
typename... Pn,
263 std::enable_if_t<std::is_invocable_v<
T const, Pn...>,
int> = 0>
264 decltype(
auto)
operator()(Pn &&...Params)
const {
265 return (*Obj)(std::forward<Pn>(Params)...);
268 bool valid()
const {
return Obj != std::nullopt; }
269 bool reset() {
return Obj = std::nullopt; }
271 operator reference() {
return *Obj; }
272 operator const_reference()
const {
return *Obj; }
278 static constexpr bool IsPtr = std::is_pointer_v<remove_cvref_t<T>>;
280 using StorageT = std::conditional_t<IsPtr, T, std::remove_reference_t<T> *>;
281 using CastT = std::conditional_t<IsPtr, T, T &>;
284 StorageT Func =
nullptr;
287 template <
typename In>
static constexpr auto convertIn(In &&
I) {
288 if constexpr (IsPtr) {
307 !std::is_same_v<remove_cvref_t<FnPtrOrRef>,
Callable>,
int
312 template <
typename... Pn,
313 std::enable_if_t<std::is_invocable_v<
T, Pn...>,
int> = 0>
314 decltype(
auto)
operator()(Pn &&...Params)
const {
315 return Func(std::forward<Pn>(Params)...);
318 bool valid()
const {
return Func !=
nullptr; }
321 operator T const &()
const {
322 if constexpr (IsPtr) {
326 static_assert(std::is_reference_v<T>,
327 "Expected a reference to a function.");
336namespace adl_detail {
340template <
typename ContainerTy>
342 return begin(std::forward<ContainerTy>(container));
347template <
typename ContainerTy>
348decltype(
auto)
adl_end(ContainerTy &&container) {
349 return end(std::forward<ContainerTy>(container));
355void adl_swap(
T &&lhs,
T &&rhs)
noexcept(
noexcept(swap(std::declval<T>(),
356 std::declval<T>()))) {
357 swap(std::forward<T>(lhs), std::forward<T>(rhs));
362template <
typename ContainerTy>
367template <
typename ContainerTy>
368decltype(
auto)
adl_end(ContainerTy &&container) {
380 auto B = std::begin(
C),
E = std::end(
C);
381 return B !=
E && std::next(
B) ==
E;
386template <
typename T>
auto drop_begin(
T &&RangeOrContainer,
size_t N = 1) {
393template <
typename T>
auto drop_end(
T &&RangeOrContainer,
size_t N = 1) {
395 std::prev(
adl_end(RangeOrContainer),
N));
401template <
typename ItTy,
typename FuncTy,
402 typename ReferenceTy =
403 decltype(std::declval<FuncTy>()(*std::declval<ItTy>()))>
406 mapped_iterator<ItTy, FuncTy>, ItTy,
407 typename std::iterator_traits<ItTy>::iterator_category,
408 std::remove_reference_t<ReferenceTy>,
409 typename std::iterator_traits<ItTy>::difference_type,
410 std::remove_reference_t<ReferenceTy> *, ReferenceTy> {
428template <
class ItTy,
class FuncTy>
433template <
class ContainerTy,
class FuncTy>
443template <
typename DerivedT,
typename ItTy,
typename ReferenceTy>
447 typename std::iterator_traits<ItTy>::iterator_category,
448 std::remove_reference_t<ReferenceTy>,
449 typename std::iterator_traits<ItTy>::difference_type,
450 std::remove_reference_t<ReferenceTy> *, ReferenceTy> {
460 return static_cast<const DerivedT &
>(*this).mapElement(*this->I);
469 template <
typename Inner>
470 static yes&
test(Inner *
I,
decltype(
I->rbegin()) * =
nullptr);
473 static no&
test(...);
476 static const bool value =
sizeof(test<Ty>(
nullptr)) ==
sizeof(yes);
480template <
typename Ty>
484template <
typename ContainerTy>
auto reverse(ContainerTy &&
C) {
488 return make_range(std::make_reverse_iterator(std::end(
C)),
489 std::make_reverse_iterator(std::begin(
C)));
508template <
typename WrappedIteratorT,
typename PredicateT,
typename IterTag>
511 filter_iterator_base<WrappedIteratorT, PredicateT, IterTag>,
513 std::common_type_t<IterTag,
514 typename std::iterator_traits<
515 WrappedIteratorT>::iterator_category>> {
523 while (this->I !=
End && !
Pred(*this->I))
539 using BaseT::operator++;
547 decltype(
auto)
operator*()
const {
548 assert(BaseT::wrapped() !=
End &&
"Cannot dereference end iterator!");
549 return BaseT::operator*();
552 decltype(
auto) operator->()
const {
553 assert(BaseT::wrapped() !=
End &&
"Cannot dereference end iterator!");
554 return BaseT::operator->();
560 typename IterTag = std::forward_iterator_tag>
572template <
typename WrappedIteratorT,
typename PredicateT>
574 std::bidirectional_iterator_tag>
576 std::bidirectional_iterator_tag> {
579 void findPrevValid() {
580 while (!this->
Pred(*this->I))
585 using BaseT::operator--;
603 using type = std::forward_iterator_tag;
607 using type = std::bidirectional_iterator_tag;
615 std::bidirectional_iterator_tag,
616 typename std::iterator_traits<IterT>::iterator_category>
::value>
::type;
623template <
typename WrappedIteratorT,
typename PredicateT>
635template <
typename RangeT,
typename PredicateT>
638 using FilterIteratorT =
641 FilterIteratorT(std::begin(std::forward<RangeT>(Range)),
642 std::end(std::forward<RangeT>(Range)), Pred),
643 FilterIteratorT(std::end(std::forward<RangeT>(Range)),
644 std::end(std::forward<RangeT>(Range)), Pred));
664template <
typename WrappedIteratorT>
667 WrappedIteratorT, std::input_iterator_tag> {
670 using PointerT =
typename std::iterator_traits<WrappedIteratorT>::pointer;
673#if LLVM_ENABLE_ABI_BREAKING_CHECKS
674 bool IsEarlyIncremented =
false;
680 using BaseT::operator*;
681 decltype(*std::declval<WrappedIteratorT>())
operator*() {
682#if LLVM_ENABLE_ABI_BREAKING_CHECKS
683 assert(!IsEarlyIncremented &&
"Cannot dereference twice!");
684 IsEarlyIncremented =
true;
689 using BaseT::operator++;
691#if LLVM_ENABLE_ABI_BREAKING_CHECKS
692 assert(IsEarlyIncremented &&
"Cannot increment before dereferencing!");
693 IsEarlyIncremented =
false;
700#if LLVM_ENABLE_ABI_BREAKING_CHECKS
701 assert(!
LHS.IsEarlyIncremented &&
"Cannot compare after dereferencing!");
703 return (
const BaseT &)
LHS == (
const BaseT &)
RHS;
719template <
typename RangeT>
720iterator_range<early_inc_iterator_impl<detail::IterOfRange<RangeT>>>
722 using EarlyIncIteratorT =
724 return make_range(EarlyIncIteratorT(std::begin(std::forward<RangeT>(Range))),
725 EarlyIncIteratorT(std::end(std::forward<RangeT>(Range))));
729template <
typename R,
typename UnaryPredicate>
730bool all_of(R &&range, UnaryPredicate
P);
732template <
typename R,
typename UnaryPredicate>
733bool any_of(R &&range, UnaryPredicate
P);
735template <
typename T>
bool all_equal(std::initializer_list<T> Values);
744 using type = std::tuple<decltype(*declval<Iters>())...>;
747template <
typename ZipType,
typename... Iters>
751 std::bidirectional_iterator_tag,
752 typename std::iterator_traits<Iters>::iterator_category...>,
755 typename std::iterator_traits<
756 std::tuple_element_t<0, std::tuple<Iters...>>>::difference_type,
764template <
typename ZipType,
typename... Iters>
776 template <
size_t... Ns>
778 return std::tuple<Iters...>(std::next(std::get<Ns>(
iterators))...);
781 template <
size_t... Ns>
783 return std::tuple<Iters...>(std::prev(std::get<Ns>(
iterators))...);
786 template <
size_t... Ns>
788 std::index_sequence<Ns...>)
const {
797 return deref(std::index_sequence_for<Iters...>{});
802 return *
reinterpret_cast<ZipType *
>(
this);
807 "All inner iterators must be at least bidirectional.");
809 return *
reinterpret_cast<ZipType *
>(
this);
818template <
typename... Iters>
829template <
typename... Iters>
831 template <
size_t... Ns>
833 std::index_sequence<Ns...>)
const {
844 return !
test(other, std::index_sequence_for<Iters...>{});
848template <
template <
typename...>
class ItType,
typename... Args>
class zippy {
850 using iterator = ItType<decltype(std::begin(std::declval<Args>()))...>;
858 std::tuple<Args...> ts;
860 template <
size_t... Ns>
861 iterator begin_impl(std::index_sequence<Ns...>)
const {
862 return iterator(std::begin(std::get<Ns>(ts))...);
864 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>)
const {
865 return iterator(std::end(std::get<Ns>(ts))...);
869 zippy(Args &&... ts_) : ts(
std::forward<Args>(ts_)...) {}
872 return begin_impl(std::index_sequence_for<Args...>{});
874 iterator end()
const {
return end_impl(std::index_sequence_for<Args...>{}); }
881template <
typename T,
typename U,
typename... Args>
885 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
891template <
typename T,
typename U,
typename... Args>
897 "Iteratees do not have equal length");
899 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
906template <
typename T,
typename U,
typename... Args>
912 "First iteratee is not the shortest");
915 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
919template <
typename Iter>
926template <
typename Iter>
928 std::remove_const_t<std::remove_reference_t<
decltype(*I)>>> {
935 using type = std::optional<std::remove_const_t<
936 std::remove_reference_t<decltype(*std::declval<Iter>())>>>;
940 using type = std::tuple<typename ZipLongestItemType<Iters>::type...>;
943template <
typename... Iters>
946 zip_longest_iterator<Iters...>,
948 std::forward_iterator_tag,
949 typename std::iterator_traits<Iters>::iterator_category...>,
950 typename ZipLongestTupleType<Iters...>::type,
951 typename std::iterator_traits<
952 std::tuple_element_t<0, std::tuple<Iters...>>>::difference_type,
953 typename ZipLongestTupleType<Iters...>::type *,
954 typename ZipLongestTupleType<Iters...>::type> {
959 std::tuple<Iters...> iterators;
960 std::tuple<Iters...> end_iterators;
962 template <
size_t... Ns>
964 std::index_sequence<Ns...>)
const {
965 return ((std::get<Ns>(this->iterators) != std::get<Ns>(other.iterators)) ||
969 template <
size_t... Ns>
value_type deref(std::index_sequence<Ns...>)
const {
971 deref_or_none(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
974 template <
size_t... Ns>
975 decltype(iterators) tup_inc(std::index_sequence<Ns...>)
const {
976 return std::tuple<Iters...>(
977 next_or_end(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
982 : iterators(
std::forward<Iters>(ts.first)...),
983 end_iterators(
std::forward<Iters>(ts.second)...) {}
986 return deref(std::index_sequence_for<Iters...>{});
990 iterators = tup_inc(std::index_sequence_for<Iters...>{});
995 return !
test(other, std::index_sequence_for<Iters...>{});
1010 std::tuple<Args...> ts;
1012 template <
size_t... Ns>
1013 iterator begin_impl(std::index_sequence<Ns...>)
const {
1015 adl_end(std::get<Ns>(ts)))...);
1018 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>)
const {
1020 adl_end(std::get<Ns>(ts)))...);
1027 return begin_impl(std::index_sequence_for<Args...>{});
1029 iterator end()
const {
return end_impl(std::index_sequence_for<Args...>{}); }
1036template <
typename T,
typename U,
typename... Args>
1040 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
1053template <
typename ValueT,
typename... IterTs>
1056 std::forward_iterator_tag, ValueT> {
1057 using BaseT =
typename concat_iterator::iterator_facade_base;
1065 std::tuple<IterTs...> Begins;
1066 std::tuple<IterTs...> Ends;
1072 template <
size_t Index>
bool incrementHelper() {
1073 auto &Begin = std::get<Index>(Begins);
1074 auto &End = std::get<Index>(Ends);
1085 template <
size_t... Ns>
void increment(std::index_sequence<Ns...>) {
1088 &concat_iterator::incrementHelper<Ns>...};
1091 for (
auto &IncrementHelperFn : IncrementHelperFns)
1092 if ((this->*IncrementHelperFn)())
1101 template <
size_t Index>
ValueT *getHelper()
const {
1102 auto &Begin = std::get<Index>(Begins);
1103 auto &End = std::get<Index>(Ends);
1114 template <
size_t... Ns>
ValueT &get(std::index_sequence<Ns...>)
const {
1117 &concat_iterator::getHelper<Ns>...};
1120 for (
auto &GetHelperFn : GetHelperFns)
1121 if (
ValueT *
P = (this->*GetHelperFn)())
1124 llvm_unreachable(
"Attempted to get a pointer from an end concat iterator!");
1132 template <
typename... RangeTs>
1134 : Begins(
std::begin(Ranges)...), Ends(
std::end(Ranges)...) {}
1136 using BaseT::operator++;
1139 increment(std::index_sequence_for<IterTs...>());
1144 return get(std::index_sequence_for<IterTs...>());
1148 return Begins ==
RHS.Begins && Ends ==
RHS.Ends;
1163 decltype(std::begin(std::declval<RangeTs &>()))...>;
1166 std::tuple<RangeTs...> Ranges;
1168 template <
size_t... Ns>
1169 iterator begin_impl(std::index_sequence<Ns...>) {
1170 return iterator(std::get<Ns>(Ranges)...);
1172 template <
size_t... Ns>
1173 iterator begin_impl(std::index_sequence<Ns...>)
const {
1174 return iterator(std::get<Ns>(Ranges)...);
1176 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>) {
1178 std::end(std::get<Ns>(Ranges)))...);
1180 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>)
const {
1182 std::end(std::get<Ns>(Ranges)))...);
1187 : Ranges(
std::forward<RangeTs>(Ranges)...) {}
1190 return begin_impl(std::index_sequence_for<RangeTs...>{});
1193 return begin_impl(std::index_sequence_for<RangeTs...>{});
1196 return end_impl(std::index_sequence_for<RangeTs...>{});
1199 return end_impl(std::index_sequence_for<RangeTs...>{});
1208template <
typename ValueT,
typename... RangeTs>
1210 static_assert(
sizeof...(RangeTs) > 1,
1211 "Need more than one range to concatenate!");
1213 std::forward<RangeTs>(Ranges)...);
1218template <
typename DerivedT,
typename BaseT,
typename T,
1219 typename PointerT =
T *,
typename ReferenceT =
T &>
1222 std::random_access_iterator_tag, T,
1223 std::ptrdiff_t, PointerT, ReferenceT> {
1238 this->
index += offset;
1239 return static_cast<DerivedT &
>(*this);
1242 this->
index -= offset;
1243 return static_cast<DerivedT &
>(*this);
1270template <
typename DerivedT,
typename BaseT,
typename T,
1271 typename PointerT =
T *,
typename ReferenceT =
T &>
1278 PointerT, ReferenceT> {
1282 return DerivedT::dereference_iterator(this->
getBase(), this->
getIndex());
1314 return (*
this)[
size() - 1];
1318 template <
typename OtherT>
1320 const OtherT &rhs) {
1321 return std::equal(lhs.
begin(), lhs.
end(), rhs.begin(), rhs.end());
1323 template <
typename OtherT>
1325 const OtherT &rhs) {
1326 return !(lhs == rhs);
1336 DerivedT
slice(
size_t n,
size_t m)
const {
1337 assert(n + m <=
size() &&
"invalid size specifiers");
1338 return DerivedT(offset_base(
base, n), m);
1343 assert(
size() >= n &&
"Dropping more elements than exist");
1348 assert(
size() >= n &&
"Dropping more elements than exist");
1355 :
static_cast<const DerivedT &
>(*this);
1361 :
static_cast<const DerivedT &
>(*this);
1365 template <
typename RangeT,
typename = std::enable_if_t<std::is_constructible<
1367 operator RangeT()
const {
1376 static BaseT offset_base(
const BaseT &
base,
size_t n) {
1377 return n == 0 ?
base : DerivedT::offset_base(
base, n);
1400template <
typename DerivedT,
typename BaseT,
typename T,
1401 typename PointerT =
T *,
typename ReferenceT =
T &>
1404 DerivedT, std::pair<BaseT, ptrdiff_t>, T, PointerT, ReferenceT> {
1408 DerivedT,
std::pair<BaseT,
ptrdiff_t>,
T, PointerT, ReferenceT>(
1411 DerivedT, std::pair<BaseT, ptrdiff_t>,
T, PointerT,
1421 static std::pair<BaseT, ptrdiff_t>
1425 return std::make_pair(
base.first,
base.second + index);
1431 return DerivedT::dereference(
base.first,
base.second + index);
1444 using type = std::conditional_t<std::is_reference<EltTy>::value, FirstTy,
1445 std::remove_reference_t<FirstTy>>;
1451 using EltTy =
decltype((*std::begin(c)));
1454 EltTy,
decltype((elt.first))>::type {
1461 using EltTy =
decltype((*std::begin(c)));
1463 std::forward<ContainerTy>(c),
1466 decltype((elt.second))>::type {
1479 return std::less<>()(lhs.first, rhs.first);
1487 return std::less<>()(lhs.second, rhs.second);
1493template<
typename FuncTy>
1497 template <
typename T>
1498 decltype(
auto)
operator()(
const T &lhs,
const T &rhs)
const {
1499 return func(lhs.first, rhs.first);
1510template <
typename T,
typename... Ts>
1511using is_one_of = std::disjunction<std::is_same<T, Ts>...>;
1515template <
typename T,
typename... Ts>
1516using are_base_of = std::conjunction<std::is_base_of<T, Ts>...>;
1521template <
typename HeadT,
typename... TailTs>
1527 using Visitor<TailTs...>::operator();
1565template <
typename... CallableTs>
1567 return detail::Visitor<CallableTs...>(std::forward<CallableTs>(Callables)...);
1576template <
class Iterator,
class RNG>
1581 typename std::iterator_traits<Iterator>::difference_type difference_type;
1582 for (
auto size = last - first;
size > 1; ++first, (void)--
size) {
1583 difference_type offset =
g() %
size;
1586 if (offset != difference_type(0))
1587 std::iter_swap(first, first + offset);
1594 if (std::less<T>()(*
reinterpret_cast<const T*
>(P1),
1595 *
reinterpret_cast<const T*
>(P2)))
1597 if (std::less<T>()(*
reinterpret_cast<const T*
>(P2),
1598 *
reinterpret_cast<const T*
>(P1)))
1607 (
const void*,
const void*) {
1608 return array_pod_sort_comparator<T>;
1611#ifdef EXPENSIVE_CHECKS
1614inline unsigned presortShuffleEntropy() {
1615 static unsigned Result(std::random_device{}());
1619template <
class IteratorTy>
1620inline void presortShuffle(IteratorTy Start, IteratorTy End) {
1621 std::mt19937 Generator(presortShuffleEntropy());
1642template<
class IteratorTy>
1646 auto NElts = End - Start;
1647 if (NElts <= 1)
return;
1648#ifdef EXPENSIVE_CHECKS
1649 detail::presortShuffle<IteratorTy>(Start, End);
1654template <
class IteratorTy>
1656 IteratorTy Start, IteratorTy End,
1658 const typename std::iterator_traits<IteratorTy>::value_type *,
1659 const typename std::iterator_traits<IteratorTy>::value_type *)) {
1662 auto NElts = End - Start;
1663 if (NElts <= 1)
return;
1664#ifdef EXPENSIVE_CHECKS
1665 detail::presortShuffle<IteratorTy>(Start, End);
1667 qsort(&*Start, NElts,
sizeof(*Start),
1668 reinterpret_cast<int (*)(
const void *,
const void *)
>(Compare));
1672template <
typename T>
1677 std::is_trivially_copyable<typename std::iterator_traits<T>::value_type>>;
1682template <
typename IteratorTy>
1683inline void sort(IteratorTy Start, IteratorTy End) {
1689#ifdef EXPENSIVE_CHECKS
1690 detail::presortShuffle<IteratorTy>(Start, End);
1692 std::sort(Start, End);
1696template <
typename Container>
inline void sort(Container &&
C) {
1700template <
typename IteratorTy,
typename Compare>
1701inline void sort(IteratorTy Start, IteratorTy End, Compare Comp) {
1702#ifdef EXPENSIVE_CHECKS
1703 detail::presortShuffle<IteratorTy>(Start, End);
1705 std::sort(Start, End, Comp);
1708template <
typename Container,
typename Compare>
1709inline void sort(Container &&
C, Compare Comp) {
1715template <
typename R>
1718 std::is_base_of<std::random_access_iterator_tag,
1719 typename std::iterator_traits<
decltype(
1720 Range.begin())>::iterator_category>
::value,
1721 void> * =
nullptr) {
1722 return std::distance(Range.begin(), Range.end());
1727template <
typename R,
typename UnaryFunction>
1734template <
typename R,
typename UnaryPredicate>
1741template <
typename R,
typename UnaryPredicate>
1748template <
typename R,
typename UnaryPredicate>
1755template <
typename R,
typename T>
auto find(R &&Range,
const T &Val) {
1761template <
typename R,
typename UnaryPredicate>
1766template <
typename R,
typename UnaryPredicate>
1773template <
typename R,
typename UnaryPredicate>
1780template <
typename R,
typename OutputIt,
typename UnaryPredicate>
1781OutputIt
copy_if(R &&Range, OutputIt Out, UnaryPredicate
P) {
1790template <
typename T,
typename R,
typename Predicate>
1793 for (
auto *
A : Range) {
1794 if (
T *PRC =
P(
A, AllowRepeats)) {
1796 if (!AllowRepeats || PRC != RC)
1814template <
typename T,
typename R,
typename Predicate>
1816 bool AllowRepeats =
false) {
1818 for (
auto *
A : Range) {
1819 std::pair<T *, bool> PRC =
P(
A, AllowRepeats);
1821 assert(PRC.first ==
nullptr &&
1822 "Inconsistent return values in find_singleton_nested.");
1827 if (!AllowRepeats || PRC.first != RC)
1828 return {
nullptr,
true};
1836template <
typename R,
typename OutputIt>
1837OutputIt
copy(R &&Range, OutputIt Out) {
1843template <
typename R,
typename OutputIt,
typename UnaryPredicate,
typename T>
1845 const T &NewValue) {
1852template <
typename R,
typename OutputIt,
typename T>
1854 const T &NewValue) {
1861template <
typename R,
typename OutputIt>
1862OutputIt
move(R &&Range, OutputIt Out) {
1868template <
typename R,
typename E>
1873template <
typename T>
1884template <
typename R,
typename Compare>
bool is_sorted(R &&Range, Compare
C) {
1896template <
typename R,
typename E>
auto count(R &&Range,
const E &Element) {
1902template <
typename R,
typename UnaryPredicate>
1909template <
typename R,
typename OutputIt,
typename UnaryFunction>
1910OutputIt
transform(R &&Range, OutputIt d_first, UnaryFunction
F) {
1916template <
typename R,
typename UnaryPredicate>
1925 std::forward<T>(
Value));
1928template <
typename R,
typename T,
typename Compare>
1931 std::forward<T>(
Value),
C);
1938 std::forward<T>(
Value));
1941template <
typename R,
typename T,
typename Compare>
1944 std::forward<T>(
Value),
C);
1947template <
typename R>
1952template <
typename R,
typename Compare>
1959template <
typename R,
typename Predicate,
1960 typename Val =
decltype(*
adl_begin(std::declval<R>()))>
1965template<
typename Range,
typename Predicate>
1972template <
typename L,
typename R>
bool equal(L &&LRange, R &&RRange) {
1981 return Begin == End || std::equal(Begin + 1, End, Begin);
1986template <
typename T>
bool all_equal(std::initializer_list<T> Values) {
1987 return all_equal<std::initializer_list<T>>(std::move(Values));
1997template <
typename Container,
typename UnaryPredicate>
2005template <
typename Container,
typename ValueType>
2007 C.erase(std::remove(
C.begin(),
C.end(), V),
C.end());
2013template <
typename Container,
typename Range>
2015 C.insert(
C.end(), R.begin(), R.end());
2020template<
typename Container,
typename RandomAccessIterator>
2021void replace(Container &Cont,
typename Container::iterator ContIt,
2022 typename Container::iterator ContEnd, RandomAccessIterator ValIt,
2023 RandomAccessIterator ValEnd) {
2025 if (ValIt == ValEnd) {
2026 Cont.erase(ContIt, ContEnd);
2028 }
else if (ContIt == ContEnd) {
2029 Cont.insert(ContIt, ValIt, ValEnd);
2032 *ContIt++ = *ValIt++;
2038template<
typename Container,
typename Range = std::initializer_list<
2039 typename Container::value_type>>
2040void replace(Container &Cont,
typename Container::iterator ContIt,
2041 typename Container::iterator ContEnd, Range R) {
2042 replace(Cont, ContIt, ContEnd, R.begin(), R.end());
2055template <
typename ForwardIterator,
typename UnaryFunctor,
2056 typename NullaryFunctor,
2057 typename = std::enable_if_t<
2058 !std::is_constructible<StringRef, UnaryFunctor>::value &&
2059 !std::is_constructible<StringRef, NullaryFunctor>::value>>
2060inline void interleave(ForwardIterator begin, ForwardIterator end,
2061 UnaryFunctor each_fn, NullaryFunctor between_fn) {
2066 for (; begin != end; ++begin) {
2072template <
typename Container,
typename UnaryFunctor,
typename NullaryFunctor,
2073 typename = std::enable_if_t<
2074 !std::is_constructible<StringRef, UnaryFunctor>::value &&
2075 !std::is_constructible<StringRef, NullaryFunctor>::value>>
2077 NullaryFunctor between_fn) {
2078 interleave(c.begin(), c.end(), each_fn, between_fn);
2082template <
typename Container,
typename UnaryFunctor,
typename StreamT,
2083 typename T = detail::ValueOfRange<Container>>
2084inline void interleave(
const Container &c, StreamT &os, UnaryFunctor each_fn,
2086 interleave(c.begin(), c.end(), each_fn, [&] { os << separator; });
2088template <
typename Container,
typename StreamT,
2089 typename T = detail::ValueOfRange<Container>>
2093 c, os, [&](
const T &a) { os << a; }, separator);
2096template <
typename Container,
typename UnaryFunctor,
typename StreamT,
2097 typename T = detail::ValueOfRange<Container>>
2099 UnaryFunctor each_fn) {
2102template <
typename Container,
typename StreamT,
2103 typename T = detail::ValueOfRange<Container>>
2118template<
typename First,
typename Second>
2121 return std::hash<First>()(
P.first) * 31 + std::hash<Second>()(
P.second);
2136 return func(*lhs, *rhs);
2142template <
typename R>
class enumerator_iter;
2146 typename std::iterator_traits<IterOfRange<R>>::reference;
2166 std::size_t
Index = std::numeric_limits<std::size_t>::max();
2170template <std::
size_t i,
typename R>
2172 static_assert(i < 2);
2173 if constexpr (i == 0) {
2174 return Pair.
index();
2176 return Pair.
value();
2180template <
typename R>
2183 const result_pair<R>> {
2188 : Result(
std::numeric_limits<size_t>::
max(), EndIter) {}
2191 : Result(
Index, Iter) {}
2196 assert(Result.Index != std::numeric_limits<size_t>::max());
2206 return Result.Iter ==
RHS.Result.Iter;
2211 Result =
Other.Result;
2270template <
typename Predicate,
typename... Args>
2273 auto it = z.begin();
2276 if (!std::apply([&](
auto &&...
args) {
return P(
args...); }, *it))
2280 return it.all_equals(end);
2285template <
typename... ArgsThenPredicate,
size_t... InputIndexes>
2287 std::tuple<ArgsThenPredicate...> argsThenPredicate,
2288 std::index_sequence<InputIndexes...>) {
2289 auto constexpr OutputIndex =
2290 std::tuple_size<
decltype(argsThenPredicate)>
::value - 1;
2292 std::get<InputIndexes>(argsThenPredicate)...);
2300template <
typename... ArgsAndPredicate>
2303 std::forward_as_tuple(argsAndPredicate...),
2304 std::make_index_sequence<
sizeof...(argsAndPredicate) - 1>{});
2310template <
typename IterTy,
2311 typename Pred =
bool (*)(
const decltype(*std::declval<IterTy>()) &)>
2313 IterTy &&Begin, IterTy &&End,
unsigned N,
2314 Pred &&ShouldBeCounted =
2315 [](
const decltype(*std::declval<IterTy>()) &) {
return true; },
2317 !std::is_base_of<std::random_access_iterator_tag,
2318 typename std::iterator_traits<std::remove_reference_t<
2319 decltype(Begin)>>::iterator_category>
::value,
2320 void> * =
nullptr) {
2321 for (;
N; ++Begin) {
2324 N -= ShouldBeCounted(*Begin);
2326 for (; Begin != End; ++Begin)
2327 if (ShouldBeCounted(*Begin))
2335template <
typename IterTy,
2336 typename Pred =
bool (*)(
const decltype(*std::declval<IterTy>()) &)>
2338 IterTy &&Begin, IterTy &&End,
unsigned N,
2339 Pred &&ShouldBeCounted =
2340 [](
const decltype(*std::declval<IterTy>()) &) {
return true; },
2342 !std::is_base_of<std::random_access_iterator_tag,
2343 typename std::iterator_traits<std::remove_reference_t<
2344 decltype(Begin)>>::iterator_category>
::value,
2345 void> * =
nullptr) {
2346 for (;
N; ++Begin) {
2349 N -= ShouldBeCounted(*Begin);
2356template <
typename IterTy,
2357 typename Pred =
bool (*)(
const decltype(*std::declval<IterTy>()) &)>
2359 IterTy &&Begin, IterTy &&End,
unsigned N,
2360 Pred &&ShouldBeCounted = [](
const decltype(*std::declval<IterTy>()) &) {
2363 assert(
N != std::numeric_limits<unsigned>::max());
2368template <
typename ContainerTy>
bool hasNItems(ContainerTy &&
C,
unsigned N) {
2373template <
typename ContainerTy>
2379template <
typename ContainerTy>
2397template <
typename R>
2398struct tuple_size<
llvm::detail::result_pair<R>>
2399 : std::integral_constant<std::size_t, 2> {};
2401template <std::
size_t i,
typename R>
2402struct tuple_element<i,
llvm::detail::result_pair<R>>
2403 : std::conditional<i == 0, std::size_t,
2404 typename llvm::detail::result_pair<R>::value_reference> {
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Given that RA is a live value
return ToRemove size() > 0
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains library features backported from future STL versions.
INLINE void g(uint32_t *state, size_t a, size_t b, size_t c, size_t d, uint32_t x, uint32_t y)
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
Templated storage wrapper for a callable.
Callable & operator=(Callable &&Other)
Callable(Callable const &Other)=default
Callable & operator=(Callable const &Other)
Callable(Callable &&Other)=default
Iterator wrapper that concatenates sequences together.
concat_iterator & operator++()
bool operator==(const concat_iterator &RHS) const
ValueT & operator*() const
concat_iterator(RangeTs &&... Ranges)
Constructs an iterator from a sequence of ranges.
Helper to store a sequence of ranges being concatenated and access them.
concat_range(RangeTs &&... Ranges)
concat_iterator< ValueT, decltype(std::begin(std::declval< RangeTs & >()))... > iterator
enumerator_iter(std::size_t Index, IterOfRange< R > Iter)
bool operator==(const enumerator_iter &RHS) const
enumerator_iter & operator++()
const result_type & operator*() const
enumerator_iter(IterOfRange< R > EndIter)
enumerator_iter & operator=(const enumerator_iter &Other)
enumerator_iter(const enumerator_iter &Other)
enumerator_iter< R > begin()
enumerator_iter< R > begin() const
enumerator_iter< R > end()
enumerator_iter< R > end() const
Return a reference to the first or second member of a reference.
std::conditional_t< std::is_reference< EltTy >::value, FirstTy, std::remove_reference_t< FirstTy > > type
An iterator element of this range.
ReferenceT operator*() const
The class represents the base of a range of indexed_accessor_iterators.
friend bool operator==(const indexed_accessor_range_base &lhs, const OtherT &rhs)
Compare this range with another.
DerivedT slice(size_t n, size_t m) const
Drop the first N elements, and keep M elements.
size_t size() const
Return the size of this range.
bool empty() const
Return if the range is empty.
indexed_accessor_range_base & operator=(const indexed_accessor_range_base &)=default
DerivedT take_front(size_t n=1) const
Take the first n elements.
ReferenceT operator[](size_t Index) const
friend bool operator!=(const indexed_accessor_range_base &lhs, const OtherT &rhs)
DerivedT drop_back(size_t n=1) const
Drop the last n elements.
DerivedT take_back(size_t n=1) const
Take the last n elements.
DerivedT drop_front(size_t n=1) const
Drop the first n elements.
indexed_accessor_range_base(const indexed_accessor_range_base &)=default
indexed_accessor_range_base(BaseT base, ptrdiff_t count)
indexed_accessor_range_base(indexed_accessor_range_base &&)=default
indexed_accessor_range_base(iterator begin, iterator end)
ptrdiff_t count
The size from the owning range.
BaseT base
The base that owns the provided range of values.
indexed_accessor_range_base(const iterator_range< iterator > &range)
const BaseT & getBase() const
Returns the base of this range.
zip_longest_iterator(std::pair< Iters &&, Iters && >... ts)
value_type operator*() const
bool operator==(const zip_longest_iterator< Iters... > &other) const
zip_longest_iterator< Iters... > & operator++()
typename ZipLongestTupleType< Iters... >::type value_type
typename iterator::iterator_category iterator_category
typename iterator::pointer pointer
zip_longest_iterator< decltype(adl_begin(std::declval< Args >()))... > iterator
typename iterator::difference_type difference_type
typename iterator::reference reference
zip_longest_range(Args &&... ts_)
typename iterator::value_type value_type
zip_shortest(Iters &&... ts)
bool operator==(const zip_shortest< Iters... > &other) const
ItType< decltype(std::begin(std::declval< Args >()))... > iterator
typename iterator::value_type value_type
typename iterator::difference_type difference_type
typename iterator::reference reference
typename iterator::pointer pointer
typename iterator::iterator_category iterator_category
A pseudo-iterator adaptor that is designed to implement "early increment" style loops.
friend bool operator==(const early_inc_iterator_impl &LHS, const early_inc_iterator_impl &RHS)
early_inc_iterator_impl(WrappedIteratorT I)
early_inc_iterator_impl & operator++()
An iterator adaptor that filters the elements of given inner iterators.
filter_iterator_base & operator++()
filter_iterator_base()=default
filter_iterator_base(WrappedIteratorT Begin, WrappedIteratorT End, PredicateT Pred)
filter_iterator_impl()=default
filter_iterator_impl(WrappedIteratorT Begin, WrappedIteratorT End, PredicateT Pred)
filter_iterator_impl & operator--()
Specialization of filter_iterator_base for forward iteration only.
filter_iterator_impl(WrappedIteratorT Begin, WrappedIteratorT End, PredicateT Pred)
filter_iterator_impl()=default
Helper to determine if type T has a member called rbegin().
A utility class used to implement an iterator that contains some base object and an index.
DerivedT & operator+=(ptrdiff_t offset)
const BaseT & getBase() const
Returns the current base of the iterator.
bool operator==(const indexed_accessor_iterator &rhs) const
indexed_accessor_iterator(BaseT base, ptrdiff_t index)
DerivedT & operator-=(ptrdiff_t offset)
ptrdiff_t operator-(const indexed_accessor_iterator &rhs) const
bool operator<(const indexed_accessor_iterator &rhs) const
ptrdiff_t getIndex() const
Returns the current index of the iterator.
This class provides an implementation of a range of indexed_accessor_iterators where the base is not ...
indexed_accessor_range(BaseT base, ptrdiff_t startIndex, ptrdiff_t count)
const BaseT & getBase() const
Returns the current base of the range.
ptrdiff_t getStartIndex() const
Returns the current start index of the range.
static ReferenceT dereference_iterator(const std::pair< BaseT, ptrdiff_t > &base, ptrdiff_t index)
See detail::indexed_accessor_range_base for details.
static std::pair< BaseT, ptrdiff_t > offset_base(const std::pair< BaseT, ptrdiff_t > &base, ptrdiff_t index)
See detail::indexed_accessor_range_base for details.
CRTP base class for adapting an iterator to a different type.
iterator_adaptor_base()=default
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
std::common_type_t< std::forward_iterator_tag, std::iterator_traits< Iters >::iterator_category... > iterator_category
std::iterator_traits< std::tuple_element_t< 0, std::tuple< Iters... > > >::difference_type difference_type
ZipLongestTupleType< Iters... >::type reference
ZipLongestTupleType< Iters... >::type * pointer
A range adaptor for a pair of iterators.
A base type of mapped iterator, that is useful for building derived iterators that do not need/want t...
mapped_iterator_base(ItTy U)
ReferenceTy operator*() const
mapped_iterator()=default
const FuncTy & getFunction() const
mapped_iterator(ItTy U, FuncTy F)
ReferenceTy operator*() const
friend const_iterator end(StringRef path)
Get end iterator over path.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ C
The default llvm calling convention, compatible with C.
void adl_swap(T &&lhs, T &&rhs) noexcept(noexcept(swap(std::declval< T >(), std::declval< T >())))
decltype(auto) adl_begin(ContainerTy &&container)
decltype(auto) adl_end(ContainerTy &&container)
auto deref_or_none(const Iter &I, const Iter &End) -> std::optional< std::remove_const_t< std::remove_reference_t< decltype(*I)> > >
bool all_of_zip_predicate_first(Predicate &&P, Args &&...args)
decltype(auto) get(const result_pair< R > &Pair)
std::conjunction< std::is_pointer< T >, std::is_trivially_copyable< typename std::iterator_traits< T >::value_type > > sort_trivially_copyable
bool all_of_zip_predicate_last(std::tuple< ArgsThenPredicate... > argsThenPredicate, std::index_sequence< InputIndexes... >)
std::remove_reference_t< decltype(*std::begin(std::declval< RangeT & >()))> ValueOfRange
Iter next_or_end(const Iter &I, const Iter &End)
decltype(std::begin(std::declval< RangeT & >())) IterOfRange
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)
zip iterator for two or more iteratable types.
void stable_sort(R &&Range)
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
std::conjunction< std::is_base_of< T, Ts >... > are_base_of
traits class for checking whether type T is a base class for all the given types in the variadic list...
UnaryFunction for_each(R &&Range, UnaryFunction F)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
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.
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...
detail::zippy< detail::zip_first, T, U, Args... > zip_equal(T &&t, U &&u, Args &&...args)
zip iterator that assumes that all iteratees have the same length.
void interleave(ForwardIterator begin, ForwardIterator end, UnaryFunctor each_fn, NullaryFunctor between_fn)
An STL-style algorithm similar to std::for_each that applies a second functor between every pair of e...
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
int array_pod_sort_comparator(const void *P1, const void *P2)
Adapt std::less<T> for array_pod_sort.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
mapped_iterator< ItTy, FuncTy > map_iterator(ItTy I, FuncTy F)
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
bool hasNItemsOrLess(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;})
Returns true if the sequence [Begin, End) has N or less items.
void interleaveComma(const Container &c, StreamT &os, UnaryFunctor each_fn)
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...
void shuffle(Iterator first, Iterator last, RNG &&g)
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
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.
auto map_range(ContainerTy &&C, FuncTy F)
typename detail::detector< void, Op, Args... >::value_t is_detected
Detects if a given trait holds for some set of arguments 'Args'.
decltype(auto) adl_begin(ContainerTy &&container)
bool hasNItemsOrMore(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;}, std::enable_if_t< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< std::remove_reference_t< decltype(Begin)> >::iterator_category >::value, void > *=nullptr)
Return true if the sequence [Begin, End) has N or more items.
OutputIt transform(R &&Range, OutputIt d_first, UnaryFunction F)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere.
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 reverse(ContainerTy &&C)
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.
void sort(IteratorTy Start, IteratorTy End)
bool hasNItems(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;}, std::enable_if_t< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< std::remove_reference_t< decltype(Begin)> >::iterator_category >::value, void > *=nullptr)
Return true if the sequence [Begin, End) has exactly N items.
auto find_if_not(R &&Range, UnaryPredicate P)
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
auto make_first_range(ContainerTy &&c)
Given a container of pairs, return a range over the first elements.
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&... Ranges)
Concatenated range across two or more ranges.
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
void adl_swap(T &&lhs, T &&rhs) noexcept(noexcept(adl_detail::adl_swap(std::declval< T >(), std::declval< T >())))
bool hasSingleElement(ContainerTy &&C)
Returns true if the given container only contains a single element.
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::pair< T *, bool > find_singleton_nested(R &&Range, Predicate P, bool AllowRepeats=false)
Return a pair consisting of the single value in Range that satisfies P(<member of Range> *,...
T * find_singleton(R &&Range, Predicate P, bool AllowRepeats=false)
Return the single value in Range that satisfies P(<member of Range> *, AllowRepeats)->T * returning n...
auto drop_end(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the last N elements excluded.
auto remove_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly.
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 lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
void erase_value(Container &C, ValueType V)
Wrapper function to remove a value from a container:
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
decltype(auto) adl_end(ContainerTy &&container)
OutputIt replace_copy_if(R &&Range, OutputIt Out, UnaryPredicate P, const T &NewValue)
Provide wrappers to std::replace_copy_if which take ranges instead of having to pass begin/end explic...
auto to_address(const Ptr &P)
Returns a raw pointer that represents the same address as the argument.
OutputIt copy(R &&Range, OutputIt Out)
auto partition(R &&Range, UnaryPredicate P)
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly.
std::disjunction< std::is_same< T, Ts >... > is_one_of
traits class for checking whether type T is one of any of the given types in the variadic list.
auto make_second_range(ContainerTy &&c)
Given a container of pairs, return a range over the second elements.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
OutputIt replace_copy(R &&Range, OutputIt Out, const T &OldValue, const T &NewValue)
Provide wrappers to std::replace_copy which take ranges instead of having to pass begin/end explicitl...
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
std::tuple_element_t< I, std::tuple< Ts... > > TypeAtIndex
Find the type at a given index in a list of types.
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 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,...
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
bool all_equal(std::initializer_list< T > Values)
Returns true if all Values in the initializer lists are equal or the list.
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
constexpr decltype(auto) makeVisitor(CallableTs &&...Callables)
Returns an opaquely-typed Callable object whose operator() overload set is the sum of the operator() ...
bool equal(L &&LRange, R &&RRange)
Wrapper function around std::equal to detect if pair-wise elements between two ranges are the same.
bool all_of_zip(ArgsAndPredicate &&...argsAndPredicate)
Compare two zipped ranges using the provided predicate (as last argument).
constexpr auto addEnumValues(EnumTy1 LHS, EnumTy2 RHS)
Helper which adds two underlying types of enumeration type.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Find the first index where a type appears in a list of types.
Determine if all types in Ts are distinct.
Binary functor that adapts to any other binary functor after dereferencing operands.
auto operator()(A &lhs, B &rhs) const
constexpr Visitor(HeadT &&Head, TailTs &&...Tail)
constexpr Visitor(HeadT &&Head)
std::optional< std::remove_const_t< std::remove_reference_t< decltype(*std::declval< Iter >())> > > type
std::tuple< typename ZipLongestItemType< Iters >::type... > type
std::tuple< decltype(*declval< Iters >())... > type
std::bidirectional_iterator_tag type
std::forward_iterator_tag type
Helper which sets its type member to forward_iterator_tag if the category of IterT does not derive fr...
typename fwd_or_bidi_tag_impl< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< IterT >::iterator_category >::value >::type type
std::size_t index() const
result_pair(std::size_t Index, IterOfRange< R > Iter)
typename std::iterator_traits< IterOfRange< R > >::reference value_reference
result_pair & operator=(const result_pair &Other)
result_pair(const result_pair< R > &Other)
value_reference value() const
value_type operator*() const
bool all_equals(zip_common &other)
Return true if all the iterator are matching other's iterators.
decltype(iterators) tup_dec(std::index_sequence< Ns... >) const
std::tuple< Iters... > iterators
zip_common(Iters &&... ts)
bool test_all_equals(const zip_common &other, std::index_sequence< Ns... >) const
typename Base::value_type value_type
value_type deref(std::index_sequence< Ns... >) const
decltype(iterators) tup_inc(std::index_sequence< Ns... >) const
bool operator==(const zip_first< Iters... > &other) const
zip_first(Iters &&... ts)
std::tuple_element_t< Index, std::tuple< Args... > > arg_t
The type of an argument to this function.
ReturnType result_t
The result type of this function.
std::tuple_element_t< i, std::tuple< Args... > > arg_t
The type of an argument to this function.
ReturnType result_t
The result type of this function.
This class provides various trait information about a callable object.
Metafunction to determine if T& or T has a member called rbegin().
Function object to check whether the first component of a std::pair compares less than the first comp...
bool operator()(const T &lhs, const T &rhs) const
Function object to check whether the second component of a std::pair compares less than the second co...
bool operator()(const T &lhs, const T &rhs) const
std::add_pointer_t< std::add_const_t< T > > type
std::add_lvalue_reference_t< std::add_const_t< T > > type
Function object to apply a binary function to the first component of a std::pair.
size_t operator()(const std::pair< First, Second > &P) const
Utility type to build an inheritance chain that makes it easy to rank overload candidates.