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
54 using type = std::add_pointer_t<std::add_const_t<T>>;
58 using type = std::add_lvalue_reference_t<std::add_const_t<T>>;
62template <
class,
template <
class...>
class Op,
class... Args>
struct detector {
65template <
template <
class...>
class Op,
class... Args>
78template <
template <
class...>
class Op,
class... Args>
85template <typename T, bool isClass = std::is_class<T>::value>
89template <
typename ClassType,
typename ReturnType,
typename... Args>
92 enum { num_args =
sizeof...(Args) };
98 template <
size_t Index>
99 using arg_t = std::tuple_element_t<
Index, std::tuple<Args...>>;
102template <
typename ClassType,
typename ReturnType,
typename... Args>
106template <
typename ReturnType,
typename... Args>
109 enum { num_args =
sizeof...(Args) };
116 using arg_t = std::tuple_element_t<i, std::tuple<Args...>>;
118template <
typename ReturnType,
typename... Args>
122template <
typename ReturnType,
typename... Args>
128template <
typename T,
typename... Ts>
129using is_one_of = std::disjunction<std::is_same<T, Ts>...>;
133template <
typename T,
typename... Ts>
138template <
typename T,
typename... Us>
140 : std::integral_constant<bool, !is_one_of<T, Us...>::value &&
141 TypesAreDistinct<Us...>::value> {};
154template <
typename... Ts>
156 : std::integral_constant<bool, detail::TypesAreDistinct<Ts...>::value> {};
169template <
typename T,
typename U,
typename... Us>
171 : std::integral_constant<size_t, 1 + FirstIndexOfType<T, Us...>::value> {};
172template <
typename T,
typename... Us>
178template <
size_t I,
typename... Ts>
183template <
typename EnumTy1,
typename EnumTy2,
184 typename UT1 = std::enable_if_t<std::is_enum<EnumTy1>::value,
185 std::underlying_type_t<EnumTy1>>,
186 typename UT2 = std::enable_if_t<std::is_enum<EnumTy2>::value,
187 std::underlying_type_t<EnumTy2>>>
189 return static_cast<UT1
>(
LHS) +
static_cast<UT2
>(
RHS);
196namespace callable_detail {
209 bool = std::is_function_v<std::remove_pointer_t<remove_cvref_t<T>>>>
211 using value_type = std::remove_reference_t<T>;
212 using reference = value_type &;
213 using const_reference = value_type
const &;
215 std::optional<value_type> Obj;
217 static_assert(!std::is_pointer_v<value_type>,
218 "Pointers to non-functions are not callable.");
230 Obj.emplace(*
Other.Obj);
237 Obj.emplace(std::move(*
Other.Obj));
241 template <
typename... Pn,
242 std::enable_if_t<std::is_invocable_v<
T, Pn...>,
int> = 0>
243 decltype(
auto)
operator()(Pn &&...Params) {
244 return (*Obj)(std::forward<Pn>(Params)...);
247 template <
typename... Pn,
248 std::enable_if_t<std::is_invocable_v<
T const, Pn...>,
int> = 0>
249 decltype(
auto)
operator()(Pn &&...Params)
const {
250 return (*Obj)(std::forward<Pn>(Params)...);
253 bool valid()
const {
return Obj != std::nullopt; }
254 bool reset() {
return Obj = std::nullopt; }
256 operator reference() {
return *Obj; }
257 operator const_reference()
const {
return *Obj; }
263 static constexpr bool IsPtr = std::is_pointer_v<remove_cvref_t<T>>;
265 using StorageT = std::conditional_t<IsPtr, T, std::remove_reference_t<T> *>;
266 using CastT = std::conditional_t<IsPtr, T, T &>;
269 StorageT Func =
nullptr;
272 template <
typename In>
static constexpr auto convertIn(In &&
I) {
273 if constexpr (IsPtr) {
292 !std::is_same_v<remove_cvref_t<FnPtrOrRef>,
Callable>,
int
297 template <
typename... Pn,
298 std::enable_if_t<std::is_invocable_v<
T, Pn...>,
int> = 0>
299 decltype(
auto)
operator()(Pn &&...Params)
const {
300 return Func(std::forward<Pn>(Params)...);
303 bool valid()
const {
return Func !=
nullptr; }
306 operator T const &()
const {
307 if constexpr (IsPtr) {
311 static_assert(std::is_reference_v<T>,
312 "Expected a reference to a function.");
323 auto B = std::begin(
C),
E = std::end(
C);
324 return B !=
E && std::next(
B) ==
E;
329template <
typename T>
auto drop_begin(
T &&RangeOrContainer,
size_t N = 1) {
336template <
typename T>
auto drop_end(
T &&RangeOrContainer,
size_t N = 1) {
338 std::prev(
adl_end(RangeOrContainer),
N));
344template <
typename ItTy,
typename FuncTy,
345 typename ReferenceTy =
346 decltype(std::declval<FuncTy>()(*std::declval<ItTy>()))>
349 mapped_iterator<ItTy, FuncTy>, ItTy,
350 typename std::iterator_traits<ItTy>::iterator_category,
351 std::remove_reference_t<ReferenceTy>,
352 typename std::iterator_traits<ItTy>::difference_type,
353 std::remove_reference_t<ReferenceTy> *, ReferenceTy> {
371template <
class ItTy,
class FuncTy>
376template <
class ContainerTy,
class FuncTy>
387template <
typename DerivedT,
typename ItTy,
typename ReferenceTy>
391 typename std::iterator_traits<ItTy>::iterator_category,
392 std::remove_reference_t<ReferenceTy>,
393 typename std::iterator_traits<ItTy>::difference_type,
394 std::remove_reference_t<ReferenceTy> *, ReferenceTy> {
404 return static_cast<const DerivedT &
>(*this).mapElement(*this->I);
409template <
typename Range>
411 decltype(
adl_rbegin(std::declval<Range &>()));
413template <
typename Range>
419template <
typename ContainerTy>
auto reverse(ContainerTy &&
C) {
420 if constexpr (detail::HasFreeFunctionRBegin<ContainerTy>)
443template <
typename WrappedIteratorT,
typename PredicateT,
typename IterTag>
446 filter_iterator_base<WrappedIteratorT, PredicateT, IterTag>,
448 std::common_type_t<IterTag,
449 typename std::iterator_traits<
450 WrappedIteratorT>::iterator_category>> {
458 while (this->I !=
End && !
Pred(*this->I))
474 using BaseT::operator++;
482 decltype(
auto)
operator*()
const {
483 assert(BaseT::wrapped() !=
End &&
"Cannot dereference end iterator!");
484 return BaseT::operator*();
487 decltype(
auto) operator->()
const {
488 assert(BaseT::wrapped() !=
End &&
"Cannot dereference end iterator!");
489 return BaseT::operator->();
495 typename IterTag = std::forward_iterator_tag>
507template <
typename WrappedIteratorT,
typename PredicateT>
509 std::bidirectional_iterator_tag>
511 std::bidirectional_iterator_tag> {
514 void findPrevValid() {
515 while (!this->
Pred(*this->I))
520 using BaseT::operator--;
538 using type = std::forward_iterator_tag;
542 using type = std::bidirectional_iterator_tag;
550 std::bidirectional_iterator_tag,
551 typename std::iterator_traits<IterT>::iterator_category>
::value>
::type;
558template <
typename WrappedIteratorT,
typename PredicateT>
570template <
typename RangeT,
typename PredicateT>
573 using FilterIteratorT =
576 FilterIteratorT(std::begin(std::forward<RangeT>(
Range)),
577 std::end(std::forward<RangeT>(
Range)), Pred),
578 FilterIteratorT(std::end(std::forward<RangeT>(
Range)),
579 std::end(std::forward<RangeT>(
Range)), Pred));
599template <
typename WrappedIteratorT>
602 WrappedIteratorT, std::input_iterator_tag> {
605 using PointerT =
typename std::iterator_traits<WrappedIteratorT>::pointer;
608#if LLVM_ENABLE_ABI_BREAKING_CHECKS
609 bool IsEarlyIncremented =
false;
615 using BaseT::operator*;
616 decltype(*std::declval<WrappedIteratorT>())
operator*() {
617#if LLVM_ENABLE_ABI_BREAKING_CHECKS
618 assert(!IsEarlyIncremented &&
"Cannot dereference twice!");
619 IsEarlyIncremented =
true;
624 using BaseT::operator++;
626#if LLVM_ENABLE_ABI_BREAKING_CHECKS
627 assert(IsEarlyIncremented &&
"Cannot increment before dereferencing!");
628 IsEarlyIncremented =
false;
635#if LLVM_ENABLE_ABI_BREAKING_CHECKS
636 assert(!
LHS.IsEarlyIncremented &&
"Cannot compare after dereferencing!");
638 return (
const BaseT &)
LHS == (
const BaseT &)
RHS;
654template <
typename RangeT>
655iterator_range<early_inc_iterator_impl<detail::IterOfRange<RangeT>>>
657 using EarlyIncIteratorT =
659 return make_range(EarlyIncIteratorT(std::begin(std::forward<RangeT>(
Range))),
660 EarlyIncIteratorT(std::end(std::forward<RangeT>(
Range))));
664template <
typename R,
typename UnaryPredicate>
665bool all_of(R &&range, UnaryPredicate
P);
667template <
typename R,
typename UnaryPredicate>
668bool any_of(R &&range, UnaryPredicate
P);
670template <
typename T>
bool all_equal(std::initializer_list<T> Values);
681 using type = std::tuple<decltype(*declval<Iters>())...>;
684template <
typename ZipType,
typename ReferenceTupleType,
typename... Iters>
688 std::bidirectional_iterator_tag,
689 typename std::iterator_traits<Iters>::iterator_category...>,
692 typename std::iterator_traits<
693 std::tuple_element_t<0, std::tuple<Iters...>>>::difference_type,
698 ReferenceTupleType *, ReferenceTupleType>;
700template <
typename ZipType,
typename ReferenceTupleType,
typename... Iters>
713 template <
size_t... Ns>
void tup_inc(std::index_sequence<Ns...>) {
717 template <
size_t... Ns>
void tup_dec(std::index_sequence<Ns...>) {
721 template <
size_t... Ns>
723 std::index_sequence<Ns...>)
const {
735 return static_cast<ZipType &
>(*this);
740 "All inner iterators must be at least bidirectional.");
742 return static_cast<ZipType &
>(*this);
751template <
typename... Iters>
753 typename ZipTupleType<Iters...>::type, Iters...> {
755 Iters...>::zip_common;
762template <
typename... Iters>
764 :
zip_common<zip_shortest<Iters...>, typename ZipTupleType<Iters...>::type,
767 Iters...>::zip_common;
770 return any_iterator_equals(other, std::index_sequence_for<Iters...>{});
774 template <
size_t... Ns>
776 std::index_sequence<Ns...>)
const {
783template <
template <
typename...>
class ItType,
typename TupleStorageType,
784 typename IndexSequence>
788template <
template <
typename...>
class ItType,
typename... Args,
791 std::index_sequence<Ns...>> {
793 std::get<Ns>(declval<std::tuple<Args...> &>())))...>;
797template <
template <
typename...>
class ItType,
typename... Args,
800 std::index_sequence<Ns...>> {
802 std::get<Ns>(declval<
const std::tuple<Args...> &>())))...>;
805template <
template <
typename...>
class ItType,
typename... Args>
class zippy {
807 std::tuple<Args...> storage;
808 using IndexSequence = std::index_sequence_for<Args...>;
812 IndexSequence>::type;
815 IndexSequence>::type;
831 template <
size_t... Ns>
835 template <
size_t... Ns>
iterator begin_impl(std::index_sequence<Ns...>) {
839 template <
size_t... Ns>
843 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>) {
852template <
typename T,
typename U,
typename...
Args>
856 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
862template <
typename T,
typename U,
typename... Args>
866 "Iteratees do not have equal length");
868 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
875template <
typename T,
typename U,
typename... Args>
879 "First iteratee is not the shortest");
882 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
886template <
typename Iter>
893template <
typename Iter>
895 std::remove_const_t<std::remove_reference_t<
decltype(*I)>>> {
902 using type = std::optional<std::remove_const_t<
903 std::remove_reference_t<decltype(*std::declval<Iter>())>>>;
907 using type = std::tuple<typename ZipLongestItemType<Iters>::type...>;
910template <
typename... Iters>
913 zip_longest_iterator<Iters...>,
915 std::forward_iterator_tag,
916 typename std::iterator_traits<Iters>::iterator_category...>,
917 typename ZipLongestTupleType<Iters...>::type,
918 typename std::iterator_traits<
919 std::tuple_element_t<0, std::tuple<Iters...>>>::difference_type,
920 typename ZipLongestTupleType<Iters...>::type *,
921 typename ZipLongestTupleType<Iters...>::type> {
926 std::tuple<Iters...> iterators;
927 std::tuple<Iters...> end_iterators;
929 template <
size_t... Ns>
931 std::index_sequence<Ns...>)
const {
932 return ((std::get<Ns>(this->iterators) != std::get<Ns>(other.iterators)) ||
936 template <
size_t... Ns>
value_type deref(std::index_sequence<Ns...>)
const {
938 deref_or_none(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
941 template <
size_t... Ns>
942 decltype(iterators) tup_inc(std::index_sequence<Ns...>)
const {
943 return std::tuple<Iters...>(
944 next_or_end(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
949 : iterators(
std::forward<Iters>(ts.first)...),
950 end_iterators(
std::forward<Iters>(ts.second)...) {}
953 return deref(std::index_sequence_for<Iters...>{});
957 iterators = tup_inc(std::index_sequence_for<Iters...>{});
962 return !
test(other, std::index_sequence_for<Iters...>{});
977 std::tuple<Args...> ts;
979 template <
size_t... Ns>
980 iterator begin_impl(std::index_sequence<Ns...>)
const {
982 adl_end(std::get<Ns>(ts)))...);
985 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>)
const {
987 adl_end(std::get<Ns>(ts)))...);
994 return begin_impl(std::index_sequence_for<Args...>{});
996 iterator end()
const {
return end_impl(std::index_sequence_for<Args...>{}); }
1003template <
typename T,
typename U,
typename... Args>
1007 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
1020template <
typename ValueT,
typename... IterTs>
1023 std::forward_iterator_tag, ValueT> {
1024 using BaseT =
typename concat_iterator::iterator_facade_base;
1032 std::tuple<IterTs...> Begins;
1033 std::tuple<IterTs...> Ends;
1039 template <
size_t Index>
bool incrementHelper() {
1040 auto &Begin = std::get<Index>(Begins);
1041 auto &
End = std::get<Index>(Ends);
1052 template <
size_t... Ns>
void increment(std::index_sequence<Ns...>) {
1055 &concat_iterator::incrementHelper<Ns>...};
1058 for (
auto &IncrementHelperFn : IncrementHelperFns)
1059 if ((this->*IncrementHelperFn)())
1068 template <
size_t Index>
ValueT *getHelper()
const {
1069 auto &Begin = std::get<Index>(Begins);
1070 auto &
End = std::get<Index>(Ends);
1081 template <
size_t... Ns>
ValueT &get(std::index_sequence<Ns...>)
const {
1084 &concat_iterator::getHelper<Ns>...};
1087 for (
auto &GetHelperFn : GetHelperFns)
1088 if (
ValueT *
P = (this->*GetHelperFn)())
1091 llvm_unreachable(
"Attempted to get a pointer from an end concat iterator!");
1099 template <
typename... RangeTs>
1101 : Begins(
std::begin(Ranges)...), Ends(
std::end(Ranges)...) {}
1103 using BaseT::operator++;
1106 increment(std::index_sequence_for<IterTs...>());
1111 return get(std::index_sequence_for<IterTs...>());
1115 return Begins ==
RHS.Begins && Ends ==
RHS.Ends;
1130 decltype(std::begin(std::declval<RangeTs &>()))...>;
1133 std::tuple<RangeTs...> Ranges;
1135 template <
size_t... Ns>
1136 iterator begin_impl(std::index_sequence<Ns...>) {
1137 return iterator(std::get<Ns>(Ranges)...);
1139 template <
size_t... Ns>
1140 iterator begin_impl(std::index_sequence<Ns...>)
const {
1141 return iterator(std::get<Ns>(Ranges)...);
1143 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>) {
1145 std::end(std::get<Ns>(Ranges)))...);
1147 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>)
const {
1149 std::end(std::get<Ns>(Ranges)))...);
1154 : Ranges(
std::forward<RangeTs>(Ranges)...) {}
1157 return begin_impl(std::index_sequence_for<RangeTs...>{});
1160 return begin_impl(std::index_sequence_for<RangeTs...>{});
1163 return end_impl(std::index_sequence_for<RangeTs...>{});
1166 return end_impl(std::index_sequence_for<RangeTs...>{});
1175template <
typename ValueT,
typename... RangeTs>
1177 static_assert(
sizeof...(RangeTs) > 1,
1178 "Need more than one range to concatenate!");
1180 std::forward<RangeTs>(Ranges)...);
1185template <
typename DerivedT,
typename BaseT,
typename T,
1186 typename PointerT =
T *,
typename ReferenceT =
T &>
1189 std::random_access_iterator_tag, T,
1190 std::ptrdiff_t, PointerT, ReferenceT> {
1205 this->
index += offset;
1206 return static_cast<DerivedT &
>(*this);
1209 this->
index -= offset;
1210 return static_cast<DerivedT &
>(*this);
1237template <
typename DerivedT,
typename BaseT,
typename T,
1238 typename PointerT =
T *,
typename ReferenceT =
T &>
1245 PointerT, ReferenceT> {
1249 return DerivedT::dereference_iterator(this->
getBase(), this->
getIndex());
1281 return (*
this)[
size() - 1];
1291 DerivedT
slice(
size_t n,
size_t m)
const {
1292 assert(n + m <=
size() &&
"invalid size specifiers");
1293 return DerivedT(offset_base(
base, n), m);
1298 assert(
size() >= n &&
"Dropping more elements than exist");
1303 assert(
size() >= n &&
"Dropping more elements than exist");
1310 :
static_cast<const DerivedT &
>(*this);
1316 :
static_cast<const DerivedT &
>(*this);
1320 template <
typename RangeT,
typename = std::enable_if_t<std::is_constructible<
1322 operator RangeT()
const {
1331 static BaseT offset_base(
const BaseT &
base,
size_t n) {
1332 return n == 0 ?
base : DerivedT::offset_base(
base, n);
1348template <
typename OtherT,
typename DerivedT,
typename BaseT,
typename T,
1349 typename PointerT,
typename ReferenceT>
1352 const OtherT &rhs) {
1353 return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
1356template <
typename OtherT,
typename DerivedT,
typename BaseT,
typename T,
1357 typename PointerT,
typename ReferenceT>
1360 const OtherT &rhs) {
1361 return !(lhs == rhs);
1372template <
typename DerivedT,
typename BaseT,
typename T,
1373 typename PointerT =
T *,
typename ReferenceT =
T &>
1376 DerivedT, std::pair<BaseT, ptrdiff_t>, T, PointerT, ReferenceT> {
1380 DerivedT,
std::pair<BaseT,
ptrdiff_t>,
T, PointerT, ReferenceT>(
1383 DerivedT, std::pair<BaseT, ptrdiff_t>,
T, PointerT,
1393 static std::pair<BaseT, ptrdiff_t>
1397 return std::make_pair(
base.first,
base.second + index);
1403 return DerivedT::dereference(
base.first,
base.second + index);
1416 using type = std::conditional_t<std::is_reference<EltTy>::value, FirstTy,
1417 std::remove_reference_t<FirstTy>>;
1423 using EltTy =
decltype((*std::begin(c)));
1426 EltTy,
decltype((elt.first))>::type {
1433 using EltTy =
decltype((*std::begin(c)));
1435 std::forward<ContainerTy>(c),
1438 decltype((elt.second))>::type {
1452 return std::less<>()(std::get<0>(lhs), std::get<0>(rhs));
1461 return std::less<>()(std::get<1>(lhs), std::get<1>(rhs));
1467template<
typename FuncTy>
1471 template <
typename T>
1472 decltype(
auto)
operator()(
const T &lhs,
const T &rhs)
const {
1473 return func(lhs.first, rhs.first);
1485template <
typename HeadT,
typename... TailTs>
1491 using Visitor<TailTs...>::operator();
1529template <
typename... CallableTs>
1531 return detail::Visitor<CallableTs...>(std::forward<CallableTs>(Callables)...);
1540template <
class Iterator,
class RNG>
1545 typename std::iterator_traits<Iterator>::difference_type difference_type;
1546 for (
auto size = last - first;
size > 1; ++first, (void)--
size) {
1547 difference_type offset =
g() %
size;
1550 if (offset != difference_type(0))
1551 std::iter_swap(first, first + offset);
1558 if (std::less<T>()(*
reinterpret_cast<const T*
>(P1),
1559 *
reinterpret_cast<const T*
>(P2)))
1561 if (std::less<T>()(*
reinterpret_cast<const T*
>(P2),
1562 *
reinterpret_cast<const T*
>(P1)))
1571 (
const void*,
const void*) {
1572 return array_pod_sort_comparator<T>;
1575#ifdef EXPENSIVE_CHECKS
1578inline unsigned presortShuffleEntropy() {
1579 static unsigned Result(std::random_device{}());
1583template <
class IteratorTy>
1584inline void presortShuffle(IteratorTy Start, IteratorTy
End) {
1585 std::mt19937 Generator(presortShuffleEntropy());
1606template<
class IteratorTy>
1610 auto NElts =
End - Start;
1611 if (NElts <= 1)
return;
1612#ifdef EXPENSIVE_CHECKS
1613 detail::presortShuffle<IteratorTy>(Start,
End);
1618template <
class IteratorTy>
1620 IteratorTy Start, IteratorTy
End,
1622 const typename std::iterator_traits<IteratorTy>::value_type *,
1623 const typename std::iterator_traits<IteratorTy>::value_type *)) {
1626 auto NElts =
End - Start;
1627 if (NElts <= 1)
return;
1628#ifdef EXPENSIVE_CHECKS
1629 detail::presortShuffle<IteratorTy>(Start,
End);
1631 qsort(&*Start, NElts,
sizeof(*Start),
1632 reinterpret_cast<int (*)(
const void *,
const void *)
>(Compare));
1636template <
typename T>
1641 std::is_trivially_copyable<typename std::iterator_traits<T>::value_type>>;
1646template <
typename IteratorTy>
1647inline void sort(IteratorTy Start, IteratorTy
End) {
1653#ifdef EXPENSIVE_CHECKS
1654 detail::presortShuffle<IteratorTy>(Start,
End);
1656 std::sort(Start,
End);
1660template <
typename Container>
inline void sort(Container &&
C) {
1664template <
typename IteratorTy,
typename Compare>
1665inline void sort(IteratorTy Start, IteratorTy
End, Compare Comp) {
1666#ifdef EXPENSIVE_CHECKS
1667 detail::presortShuffle<IteratorTy>(Start,
End);
1669 std::sort(Start,
End, Comp);
1672template <
typename Container,
typename Compare>
1673inline void sort(Container &&
C, Compare Comp) {
1679template <
typename R>
1682 std::is_base_of<std::random_access_iterator_tag,
1683 typename std::iterator_traits<
decltype(
1685 void> * =
nullptr) {
1686 return std::distance(
Range.begin(),
Range.end());
1690template <
typename Range>
1692 decltype(
adl_size(std::declval<Range &>()));
1694template <
typename Range>
1706 if constexpr (detail::HasFreeFunctionSize<R>)
1714template <
typename R,
typename UnaryFunction>
1721template <
typename R,
typename UnaryPredicate>
1728template <
typename R,
typename UnaryPredicate>
1735template <
typename R,
typename UnaryPredicate>
1742template <
typename R,
typename T>
auto find(R &&
Range,
const T &Val) {
1748template <
typename R,
typename UnaryPredicate>
1753template <
typename R,
typename UnaryPredicate>
1760template <
typename R,
typename UnaryPredicate>
1767template <
typename R,
typename OutputIt,
typename UnaryPredicate>
1777template <
typename T,
typename R,
typename Predicate>
1781 if (
T *PRC =
P(
A, AllowRepeats)) {
1783 if (!AllowRepeats || PRC != RC)
1801template <
typename T,
typename R,
typename Predicate>
1803 bool AllowRepeats =
false) {
1806 std::pair<T *, bool> PRC =
P(
A, AllowRepeats);
1808 assert(PRC.first ==
nullptr &&
1809 "Inconsistent return values in find_singleton_nested.");
1814 if (!AllowRepeats || PRC.first != RC)
1815 return {
nullptr,
true};
1823template <
typename R,
typename OutputIt>
1830template <
typename R,
typename OutputIt,
typename UnaryPredicate,
typename T>
1832 const T &NewValue) {
1839template <
typename R,
typename OutputIt,
typename T>
1841 const T &NewValue) {
1848template <
typename R,
typename OutputIt>
1854template <
typename Range,
typename Element>
1856 decltype(std::declval<Range &>().contains(std::declval<const Element &>()));
1858template <
typename Range,
typename Element>
1862template <
typename Range,
typename Element>
1864 decltype(std::declval<Range &>().find(std::declval<const Element &>()) !=
1865 std::declval<Range &>().end());
1867template <
typename Range,
typename Element>
1878template <
typename R,
typename E>
1880 if constexpr (detail::HasMemberContains<R, E>)
1882 else if constexpr (detail::HasMemberFind<R, E>)
1891template <
typename T,
typename E>
1894 for (
const T &V : Set)
1914template <
typename R,
typename E>
auto count(R &&
Range,
const E &Element) {
1920template <
typename R,
typename UnaryPredicate>
1927template <
typename R,
typename OutputIt,
typename UnaryFunction>
1934template <
typename R,
typename UnaryPredicate>
1943 std::forward<T>(
Value));
1946template <
typename R,
typename T,
typename Compare>
1949 std::forward<T>(
Value),
C);
1956 std::forward<T>(
Value));
1959template <
typename R,
typename T,
typename Compare>
1962 std::forward<T>(
Value),
C);
1969 std::forward<T>(
Value));
1972template <
typename R,
typename T,
typename Compare>
1975 std::forward<T>(
Value),
C);
1994template <
typename R>
1999template <
typename R,
typename Compare>
2006template <
typename R,
typename Predicate,
2007 typename Val =
decltype(*
adl_begin(std::declval<R>()))>
2012template<
typename Range,
typename Predicate>
2025template <
typename L,
typename R>
bool equal(L &&LRange, R &&RRange) {
2030template <
typename L,
typename R,
typename BinaryPredicate>
2031bool equal(L &&LRange, R &&RRange, BinaryPredicate
P) {
2040 return Begin ==
End || std::equal(Begin + 1,
End, Begin);
2045template <
typename T>
bool all_equal(std::initializer_list<T> Values) {
2046 return all_equal<std::initializer_list<T>>(std::move(Values));
2056template <
typename Container,
typename UnaryPredicate>
2064template <
typename Container,
typename ValueType>
2066 C.erase(std::remove(
C.begin(),
C.end(), V),
C.end());
2072template <
typename Container,
typename Range>
2078template <
typename Container,
typename... Args>
2082 ((void)
C.insert(
C.end(), std::forward<Args>(Values)), ...);
2087template<
typename Container,
typename RandomAccessIterator>
2088void replace(Container &Cont,
typename Container::iterator ContIt,
2089 typename Container::iterator ContEnd, RandomAccessIterator ValIt,
2090 RandomAccessIterator ValEnd) {
2092 if (ValIt == ValEnd) {
2093 Cont.erase(ContIt, ContEnd);
2095 }
else if (ContIt == ContEnd) {
2096 Cont.insert(ContIt, ValIt, ValEnd);
2099 *ContIt++ = *ValIt++;
2105template<
typename Container,
typename Range = std::initializer_list<
2106 typename Container::value_type>>
2107void replace(Container &Cont,
typename Container::iterator ContIt,
2108 typename Container::iterator ContEnd,
Range R) {
2109 replace(Cont, ContIt, ContEnd, R.begin(), R.end());
2122template <
typename ForwardIterator,
typename UnaryFunctor,
2123 typename NullaryFunctor,
2124 typename = std::enable_if_t<
2125 !std::is_constructible<StringRef, UnaryFunctor>::value &&
2126 !std::is_constructible<StringRef, NullaryFunctor>::value>>
2127inline void interleave(ForwardIterator begin, ForwardIterator end,
2128 UnaryFunctor each_fn, NullaryFunctor between_fn) {
2133 for (; begin != end; ++begin) {
2139template <
typename Container,
typename UnaryFunctor,
typename NullaryFunctor,
2140 typename = std::enable_if_t<
2141 !std::is_constructible<StringRef, UnaryFunctor>::value &&
2142 !std::is_constructible<StringRef, NullaryFunctor>::value>>
2144 NullaryFunctor between_fn) {
2149template <
typename Container,
typename UnaryFunctor,
typename StreamT,
2150 typename T = detail::ValueOfRange<Container>>
2151inline void interleave(
const Container &c, StreamT &os, UnaryFunctor each_fn,
2155template <
typename Container,
typename StreamT,
2156 typename T = detail::ValueOfRange<Container>>
2160 c, os, [&](
const T &a) { os << a; }, separator);
2163template <
typename Container,
typename UnaryFunctor,
typename StreamT,
2164 typename T = detail::ValueOfRange<Container>>
2166 UnaryFunctor each_fn) {
2169template <
typename Container,
typename StreamT,
2170 typename T = detail::ValueOfRange<Container>>
2185template<
typename First,
typename Second>
2188 return std::hash<First>()(
P.first) * 31 + std::hash<Second>()(
P.second);
2203 return func(*lhs, *rhs);
2212template <
typename... Iters>
2226template <
typename... Iters>
2228 EnumeratorTupleType<Iters...>, Iters...> {
2229 static_assert(
sizeof...(Iters) >= 2,
"Expected at least two iteratees");
2231 Iters...>::zip_common;
2234 return std::get<1>(this->
iterators) == std::get<1>(
Other.iterators);
2239 static constexpr std::size_t NumRefs =
sizeof...(Refs);
2240 static_assert(NumRefs != 0);
2242 static constexpr std::size_t NumValues = NumRefs + 1;
2251 :
Idx(
Index), Storage(
std::forward<Refs>(Rs)...) {}
2260 if constexpr (NumRefs == 1)
2261 return std::get<0>(Storage);
2267 template <std::
size_t I,
typename = std::enable_if_t<I == 0>>
2274 template <std::
size_t I,
typename = std::enable_if_t<I != 0>>
2279 return std::get<
I - 1>(Result.Storage);
2282 template <
typename... Ts>
2284 const std::tuple<std::size_t, Ts...> &
Other) {
2285 static_assert(NumRefs ==
sizeof...(Ts),
"Size mismatch");
2286 if (Result.Idx != std::get<0>(
Other))
2288 return Result.is_value_equal(
Other, std::make_index_sequence<NumRefs>{});
2292 template <
typename Tuple, std::size_t...
Idx>
2293 bool is_value_equal(
const Tuple &
Other, std::index_sequence<Idx...>)
const {
2294 return ((std::get<Idx>(Storage) == std::get<Idx + 1>(
Other)) && ...);
2305 mutable range_reference_tuple Storage;
2310 std::random_access_iterator_tag, std::size_t> {
2324 return Index - R.Index;
2335 return Lhs.Index == Rhs.Index;
2339 return Lhs.Index < Rhs.Index;
2405template <
typename FirstRange,
typename... RestRanges>
2407 if constexpr (
sizeof...(Rest) != 0) {
2416 FirstRange, RestRanges...>;
2418 std::forward<RestRanges>(Rest)...);
2423template <
typename Predicate,
typename... Args>
2426 auto it = z.begin();
2429 if (!std::apply([&](
auto &&...
args) {
return P(
args...); }, *it))
2433 return it.all_equals(end);
2438template <
typename... ArgsThenPredicate,
size_t... InputIndexes>
2440 std::tuple<ArgsThenPredicate...> argsThenPredicate,
2441 std::index_sequence<InputIndexes...>) {
2442 auto constexpr OutputIndex =
2443 std::tuple_size<
decltype(argsThenPredicate)>
::value - 1;
2445 std::get<InputIndexes>(argsThenPredicate)...);
2453template <
typename... ArgsAndPredicate>
2456 std::forward_as_tuple(argsAndPredicate...),
2457 std::make_index_sequence<
sizeof...(argsAndPredicate) - 1>{});
2463template <
typename IterTy,
2464 typename Pred =
bool (*)(
const decltype(*std::declval<IterTy>()) &)>
2466 IterTy &&Begin, IterTy &&
End,
unsigned N,
2467 Pred &&ShouldBeCounted =
2468 [](
const decltype(*std::declval<IterTy>()) &) {
return true; },
2470 !std::is_base_of<std::random_access_iterator_tag,
2471 typename std::iterator_traits<std::remove_reference_t<
2472 decltype(Begin)>>::iterator_category>
::value,
2473 void> * =
nullptr) {
2474 for (;
N; ++Begin) {
2477 N -= ShouldBeCounted(*Begin);
2479 for (; Begin !=
End; ++Begin)
2480 if (ShouldBeCounted(*Begin))
2488template <
typename IterTy,
2489 typename Pred =
bool (*)(
const decltype(*std::declval<IterTy>()) &)>
2491 IterTy &&Begin, IterTy &&
End,
unsigned N,
2492 Pred &&ShouldBeCounted =
2493 [](
const decltype(*std::declval<IterTy>()) &) {
return true; },
2495 !std::is_base_of<std::random_access_iterator_tag,
2496 typename std::iterator_traits<std::remove_reference_t<
2497 decltype(Begin)>>::iterator_category>
::value,
2498 void> * =
nullptr) {
2499 for (;
N; ++Begin) {
2502 N -= ShouldBeCounted(*Begin);
2509template <
typename IterTy,
2510 typename Pred =
bool (*)(
const decltype(*std::declval<IterTy>()) &)>
2512 IterTy &&Begin, IterTy &&
End,
unsigned N,
2513 Pred &&ShouldBeCounted = [](
const decltype(*std::declval<IterTy>()) &) {
2516 assert(
N != std::numeric_limits<unsigned>::max());
2521template <
typename ContainerTy>
bool hasNItems(ContainerTy &&
C,
unsigned N) {
2526template <
typename ContainerTy>
2532template <
typename ContainerTy>
2554template <
typename T>
2560template <
typename... Refs>
2561struct tuple_size<
llvm::detail::enumerator_result<Refs...>>
2562 : std::integral_constant<std::size_t, sizeof...(Refs)> {};
2564template <std::size_t
I,
typename... Refs>
2565struct tuple_element<
I,
llvm::detail::enumerator_result<Refs...>>
2566 : std::tuple_element<I, std::tuple<Refs...>> {};
2568template <std::size_t
I,
typename... Refs>
2569struct tuple_element<
I,
const llvm::detail::enumerator_result<Refs...>>
2570 : std::tuple_element<I, std::tuple<Refs...>> {};
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")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live value
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
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)
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
This class represents an Operation in the Expression.
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
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.
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
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
typename iterator::value_type value_type
typename iterator::difference_type difference_type
typename iterator::reference reference
typename iterator::pointer pointer
typename const_iterator::reference const_reference
typename ZippyIteratorTuple< ItType, decltype(storage), IndexSequence >::type iterator
typename ZippyIteratorTuple< ItType, const decltype(storage), IndexSequence >::type const_iterator
const_iterator begin() const
typename iterator::iterator_category iterator_category
const_iterator end() const
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
Increasing range of size_t indices.
index_range(std::size_t Begin, std::size_t End)
detail::index_iterator begin() const
detail::index_iterator end() const
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.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ 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.
auto deref_or_none(const Iter &I, const Iter &End) -> std::optional< std::remove_const_t< std::remove_reference_t< decltype(*I)> > >
decltype(std::declval< Range & >().contains(std::declval< const Element & >())) check_has_member_contains_t
decltype(std::declval< Range & >().find(std::declval< const Element & >()) !=std::declval< Range & >().end()) check_has_member_find_t
bool all_of_zip_predicate_first(Predicate &&P, Args &&...args)
static constexpr bool HasMemberFind
std::conjunction< std::is_pointer< T >, std::is_trivially_copyable< typename std::iterator_traits< T >::value_type > > sort_trivially_copyable
static constexpr bool HasFreeFunctionRBegin
bool operator!=(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)
Inequality comparison for DenseSet.
static constexpr bool HasMemberContains
decltype(sizeof(T)) has_sizeof
bool all_of_zip_predicate_last(std::tuple< ArgsThenPredicate... > argsThenPredicate, std::index_sequence< InputIndexes... >)
Iter next_or_end(const Iter &I, const Iter &End)
decltype(adl_rbegin(std::declval< Range & >())) check_has_free_function_rbegin
static constexpr bool HasFreeFunctionSize
decltype(adl_size(std::declval< Range & >())) check_has_free_function_size
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...
auto min_element(R &&Range)
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.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
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...
constexpr bool is_incomplete_v
Detects when type T is incomplete.
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.
constexpr auto adl_begin(RangeT &&range) -> decltype(adl_detail::begin_impl(std::forward< RangeT >(range)))
Returns the begin iterator to range using std::begin and function found through Argument-Dependent Lo...
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
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 range R to container C.
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)
constexpr auto adl_end(RangeT &&range) -> decltype(adl_detail::end_impl(std::forward< RangeT >(range)))
Returns the end iterator to range using std::end and functions found through Argument-Dependent Looku...
auto unique(Range &&R, Predicate P)
auto binary_search(R &&Range, T &&Value)
Provide wrappers to std::binary_search which take ranges instead of having to pass begin/end explicit...
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.
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
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'.
constexpr auto adl_rbegin(RangeT &&range) -> decltype(adl_detail::rbegin_impl(std::forward< RangeT >(range)))
Returns the reverse-begin iterator to range using std::rbegin and function found through Argument-Dep...
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.
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
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)
constexpr size_t range_size(R &&Range)
Returns the size of the Range, i.e., the number of elements.
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.
constexpr auto adl_size(RangeT &&range) -> decltype(adl_detail::size_impl(std::forward< RangeT >(range)))
Returns the size of range using std::size and functions found through Argument-Dependent Lookup (ADL)...
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...
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.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
auto remove_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly.
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
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...
DWARFExpression::Operation Op
auto max_element(R &&Range)
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...
constexpr auto adl_rend(RangeT &&range) -> decltype(adl_detail::rend_impl(std::forward< RangeT >(range)))
Returns the reverse-end iterator to range using std::rend and functions found through Argument-Depend...
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,...
void append_values(Container &C, Args &&...Values)
Appends all Values to container C.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
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.
Implement std::hash so that hash_code can be used in STL containers.
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
ItType< decltype(adl_begin(std::get< Ns >(declval< const std::tuple< Args... > & >())))... > type
ItType< decltype(adl_begin(std::get< Ns >(declval< std::tuple< Args... > & >())))... > type
Helper to obtain the iterator types for the tuple storage within zippy.
std::tuple< Refs... > range_reference_tuple
decltype(auto) value() const
Returns the value(s) for the current iterator.
friend decltype(auto) get(const enumerator_result &Result)
Returns the value at index I.
std::tuple< std::size_t, Refs... > value_reference_tuple
friend bool operator==(const enumerator_result &Result, const std::tuple< std::size_t, Ts... > &Other)
std::size_t index() const
Returns the 0-based index of the current position within the original input range(s).
friend std::size_t get(const enumerator_result &Result)
Returns the value at index I. This case covers the index.
enumerator_result(std::size_t Index, Refs &&...Rs)
Tuple-like type for zip_enumerator dereference.
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
friend bool operator==(const index_iterator &Lhs, const index_iterator &Rhs)
std::ptrdiff_t operator-(const index_iterator &R) const
std::size_t operator*() const
friend bool operator<(const index_iterator &Lhs, const index_iterator &Rhs)
index_iterator & operator-=(std::ptrdiff_t N)
index_iterator & operator+=(std::ptrdiff_t N)
index_iterator(std::size_t Index)
Infinite stream of increasing 0-based size_t indices.
index_iterator begin() const
index_iterator end() const
std::index_sequence_for< Iters... > IndexSequence
void tup_inc(std::index_sequence< Ns... >)
zip_common(Iters &&... ts)
bool test_all_equals(const zip_common &other, std::index_sequence< Ns... >) const
std::tuple< Iters... > iterators
value_type operator*() const
typename Base::value_type value_type
bool all_equals(zip_common &other)
Return true if all the iterator are matching other's iterators.
void tup_dec(std::index_sequence< Ns... >)
value_type deref(std::index_sequence< Ns... >) const
Zippy iterator that uses the second iterator for comparisons.
bool operator==(const zip_enumerator &Other) const
bool operator==(const zip_first &other) const
bool operator==(const zip_shortest &other) const
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.
Function object to check whether the first component of a container supported by std::get (like std::...
bool operator()(const T &lhs, const T &rhs) const
Function object to check whether the second component of a container supported by std::get (like std:...
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.