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>
420template <
typename ContainerTy> [[nodiscard]]
auto reverse(ContainerTy &&
C) {
421 if constexpr (detail::HasFreeFunctionRBegin<ContainerTy>)
444template <
typename WrappedIteratorT,
typename PredicateT,
typename IterTag>
447 filter_iterator_base<WrappedIteratorT, PredicateT, IterTag>,
449 std::common_type_t<IterTag,
450 typename std::iterator_traits<
451 WrappedIteratorT>::iterator_category>> {
459 while (this->I !=
End && !
Pred(*this->I))
475 using BaseT::operator++;
483 decltype(
auto)
operator*()
const {
484 assert(BaseT::wrapped() !=
End &&
"Cannot dereference end iterator!");
485 return BaseT::operator*();
488 decltype(
auto) operator->()
const {
489 assert(BaseT::wrapped() !=
End &&
"Cannot dereference end iterator!");
490 return BaseT::operator->();
496 typename IterTag = std::forward_iterator_tag>
508template <
typename WrappedIteratorT,
typename PredicateT>
510 std::bidirectional_iterator_tag>
512 std::bidirectional_iterator_tag> {
515 void findPrevValid() {
516 while (!this->
Pred(*this->I))
521 using BaseT::operator--;
539 using type = std::forward_iterator_tag;
543 using type = std::bidirectional_iterator_tag;
551 std::bidirectional_iterator_tag,
552 typename std::iterator_traits<IterT>::iterator_category>
::value>
::type;
559template <
typename WrappedIteratorT,
typename PredicateT>
571template <
typename RangeT,
typename PredicateT>
574 using FilterIteratorT =
577 FilterIteratorT(std::begin(std::forward<RangeT>(
Range)),
578 std::end(std::forward<RangeT>(
Range)), Pred),
579 FilterIteratorT(std::end(std::forward<RangeT>(
Range)),
580 std::end(std::forward<RangeT>(
Range)), Pred));
600template <
typename WrappedIteratorT>
603 WrappedIteratorT, std::input_iterator_tag> {
606 using PointerT =
typename std::iterator_traits<WrappedIteratorT>::pointer;
609#if LLVM_ENABLE_ABI_BREAKING_CHECKS
610 bool IsEarlyIncremented =
false;
616 using BaseT::operator*;
617 decltype(*std::declval<WrappedIteratorT>())
operator*() {
618#if LLVM_ENABLE_ABI_BREAKING_CHECKS
619 assert(!IsEarlyIncremented &&
"Cannot dereference twice!");
620 IsEarlyIncremented =
true;
625 using BaseT::operator++;
627#if LLVM_ENABLE_ABI_BREAKING_CHECKS
628 assert(IsEarlyIncremented &&
"Cannot increment before dereferencing!");
629 IsEarlyIncremented =
false;
636#if LLVM_ENABLE_ABI_BREAKING_CHECKS
637 assert(!
LHS.IsEarlyIncremented &&
"Cannot compare after dereferencing!");
639 return (
const BaseT &)
LHS == (
const BaseT &)
RHS;
655template <
typename RangeT>
656iterator_range<early_inc_iterator_impl<detail::IterOfRange<RangeT>>>
658 using EarlyIncIteratorT =
660 return make_range(EarlyIncIteratorT(std::begin(std::forward<RangeT>(
Range))),
661 EarlyIncIteratorT(std::end(std::forward<RangeT>(
Range))));
665template <
typename R,
typename UnaryPredicate>
666bool all_of(R &&range, UnaryPredicate
P);
668template <
typename R,
typename UnaryPredicate>
669bool any_of(R &&range, UnaryPredicate
P);
671template <
typename T>
bool all_equal(std::initializer_list<T> Values);
682 using type = std::tuple<decltype(*declval<Iters>())...>;
685template <
typename ZipType,
typename ReferenceTupleType,
typename... Iters>
689 std::bidirectional_iterator_tag,
690 typename std::iterator_traits<Iters>::iterator_category...>,
693 typename std::iterator_traits<
694 std::tuple_element_t<0, std::tuple<Iters...>>>::difference_type,
699 ReferenceTupleType *, ReferenceTupleType>;
701template <
typename ZipType,
typename ReferenceTupleType,
typename... Iters>
714 template <
size_t... Ns>
void tup_inc(std::index_sequence<Ns...>) {
718 template <
size_t... Ns>
void tup_dec(std::index_sequence<Ns...>) {
722 template <
size_t... Ns>
724 std::index_sequence<Ns...>)
const {
736 return static_cast<ZipType &
>(*this);
741 "All inner iterators must be at least bidirectional.");
743 return static_cast<ZipType &
>(*this);
752template <
typename... Iters>
754 typename ZipTupleType<Iters...>::type, Iters...> {
756 Iters...>::zip_common;
763template <
typename... Iters>
765 :
zip_common<zip_shortest<Iters...>, typename ZipTupleType<Iters...>::type,
768 Iters...>::zip_common;
771 return any_iterator_equals(other, std::index_sequence_for<Iters...>{});
775 template <
size_t... Ns>
777 std::index_sequence<Ns...>)
const {
784template <
template <
typename...>
class ItType,
typename TupleStorageType,
785 typename IndexSequence>
789template <
template <
typename...>
class ItType,
typename... Args,
792 std::index_sequence<Ns...>> {
794 std::get<Ns>(declval<std::tuple<Args...> &>())))...>;
798template <
template <
typename...>
class ItType,
typename... Args,
801 std::index_sequence<Ns...>> {
803 std::get<Ns>(declval<
const std::tuple<Args...> &>())))...>;
806template <
template <
typename...>
class ItType,
typename... Args>
class zippy {
808 std::tuple<Args...> storage;
809 using IndexSequence = std::index_sequence_for<Args...>;
813 IndexSequence>::type;
816 IndexSequence>::type;
832 template <
size_t... Ns>
836 template <
size_t... Ns>
iterator begin_impl(std::index_sequence<Ns...>) {
840 template <
size_t... Ns>
844 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>) {
853template <
typename T,
typename U,
typename...
Args>
857 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
863template <
typename T,
typename U,
typename... Args>
867 "Iteratees do not have equal length");
869 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
876template <
typename T,
typename U,
typename... Args>
880 "First iteratee is not the shortest");
883 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
887template <
typename Iter>
894template <
typename Iter>
896 std::remove_const_t<std::remove_reference_t<
decltype(*I)>>> {
903 using type = std::optional<std::remove_const_t<
904 std::remove_reference_t<decltype(*std::declval<Iter>())>>>;
908 using type = std::tuple<typename ZipLongestItemType<Iters>::type...>;
911template <
typename... Iters>
914 zip_longest_iterator<Iters...>,
916 std::forward_iterator_tag,
917 typename std::iterator_traits<Iters>::iterator_category...>,
918 typename ZipLongestTupleType<Iters...>::type,
919 typename std::iterator_traits<
920 std::tuple_element_t<0, std::tuple<Iters...>>>::difference_type,
921 typename ZipLongestTupleType<Iters...>::type *,
922 typename ZipLongestTupleType<Iters...>::type> {
927 std::tuple<Iters...> iterators;
928 std::tuple<Iters...> end_iterators;
930 template <
size_t... Ns>
932 std::index_sequence<Ns...>)
const {
933 return ((std::get<Ns>(this->iterators) != std::get<Ns>(other.iterators)) ||
937 template <
size_t... Ns>
value_type deref(std::index_sequence<Ns...>)
const {
939 deref_or_none(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
942 template <
size_t... Ns>
943 decltype(iterators) tup_inc(std::index_sequence<Ns...>)
const {
944 return std::tuple<Iters...>(
945 next_or_end(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
950 : iterators(
std::forward<Iters>(ts.first)...),
951 end_iterators(
std::forward<Iters>(ts.second)...) {}
954 return deref(std::index_sequence_for<Iters...>{});
958 iterators = tup_inc(std::index_sequence_for<Iters...>{});
963 return !
test(other, std::index_sequence_for<Iters...>{});
978 std::tuple<Args...> ts;
980 template <
size_t... Ns>
981 iterator begin_impl(std::index_sequence<Ns...>)
const {
983 adl_end(std::get<Ns>(ts)))...);
986 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>)
const {
988 adl_end(std::get<Ns>(ts)))...);
995 return begin_impl(std::index_sequence_for<Args...>{});
997 iterator end()
const {
return end_impl(std::index_sequence_for<Args...>{}); }
1004template <
typename T,
typename U,
typename... Args>
1008 std::forward<T>(t), std::forward<U>(u), std::forward<Args>(
args)...);
1021template <
typename ValueT,
typename... IterTs>
1024 std::forward_iterator_tag, ValueT> {
1025 using BaseT =
typename concat_iterator::iterator_facade_base;
1027 static constexpr bool ReturnsByValue =
1028 !(std::is_reference_v<decltype(*std::declval<IterTs>())> && ...);
1030 using reference_type =
1031 typename std::conditional_t<ReturnsByValue, ValueT, ValueT &>;
1034 typename std::conditional_t<ReturnsByValue, std::optional<ValueT>,
1043 std::tuple<IterTs...> Begins;
1044 std::tuple<IterTs...> Ends;
1050 template <
size_t Index>
bool incrementHelper() {
1051 auto &Begin = std::get<Index>(Begins);
1052 auto &
End = std::get<Index>(Ends);
1063 template <
size_t... Ns>
void increment(std::index_sequence<Ns...>) {
1066 &concat_iterator::incrementHelper<Ns>...};
1069 for (
auto &IncrementHelperFn : IncrementHelperFns)
1070 if ((this->*IncrementHelperFn)())
1079 template <
size_t Index> handle_type getHelper()
const {
1080 auto &Begin = std::get<Index>(Begins);
1081 auto &
End = std::get<Index>(Ends);
1085 if constexpr (ReturnsByValue)
1095 template <
size_t... Ns> reference_type get(std::index_sequence<Ns...>)
const {
1098 const = {&concat_iterator::getHelper<Ns>...};
1101 for (
auto &GetHelperFn : GetHelperFns)
1102 if (
auto P = (this->*GetHelperFn)())
1105 llvm_unreachable(
"Attempted to get a pointer from an end concat iterator!");
1113 template <
typename... RangeTs>
1115 : Begins(
std::begin(Ranges)...), Ends(
std::end(Ranges)...) {}
1117 using BaseT::operator++;
1120 increment(std::index_sequence_for<IterTs...>());
1125 return get(std::index_sequence_for<IterTs...>());
1129 return Begins ==
RHS.Begins && Ends ==
RHS.Ends;
1144 decltype(std::begin(std::declval<RangeTs &>()))...>;
1147 std::tuple<RangeTs...> Ranges;
1149 template <
size_t... Ns>
1150 iterator begin_impl(std::index_sequence<Ns...>) {
1151 return iterator(std::get<Ns>(Ranges)...);
1153 template <
size_t... Ns>
1154 iterator begin_impl(std::index_sequence<Ns...>)
const {
1155 return iterator(std::get<Ns>(Ranges)...);
1157 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>) {
1159 std::end(std::get<Ns>(Ranges)))...);
1161 template <
size_t... Ns>
iterator end_impl(std::index_sequence<Ns...>)
const {
1163 std::end(std::get<Ns>(Ranges)))...);
1168 : Ranges(
std::forward<RangeTs>(Ranges)...) {}
1171 return begin_impl(std::index_sequence_for<RangeTs...>{});
1174 return begin_impl(std::index_sequence_for<RangeTs...>{});
1177 return end_impl(std::index_sequence_for<RangeTs...>{});
1180 return end_impl(std::index_sequence_for<RangeTs...>{});
1190template <
typename ValueT,
typename... RangeTs>
1191[[nodiscard]] detail::concat_range<
ValueT, RangeTs...>
1193 static_assert(
sizeof...(RangeTs) > 1,
1194 "Need more than one range to concatenate!");
1196 std::forward<RangeTs>(Ranges)...);
1201template <
typename DerivedT,
typename BaseT,
typename T,
1202 typename PointerT =
T *,
typename ReferenceT =
T &>
1205 std::random_access_iterator_tag, T,
1206 std::ptrdiff_t, PointerT, ReferenceT> {
1222 this->
index += offset;
1223 return static_cast<DerivedT &
>(*this);
1226 this->
index -= offset;
1227 return static_cast<DerivedT &
>(*this);
1254template <
typename DerivedT,
typename BaseT,
typename T,
1255 typename PointerT =
T *,
typename ReferenceT =
T &>
1262 PointerT, ReferenceT> {
1266 return DerivedT::dereference_iterator(this->
getBase(), this->
getIndex());
1298 return (*
this)[
size() - 1];
1308 DerivedT
slice(
size_t n,
size_t m)
const {
1309 assert(n + m <=
size() &&
"invalid size specifiers");
1310 return DerivedT(offset_base(
base, n), m);
1315 assert(
size() >= n &&
"Dropping more elements than exist");
1320 assert(
size() >= n &&
"Dropping more elements than exist");
1327 :
static_cast<const DerivedT &
>(*this);
1333 :
static_cast<const DerivedT &
>(*this);
1337 template <
typename RangeT,
typename = std::enable_if_t<std::is_constructible<
1339 operator RangeT()
const {
1348 static BaseT offset_base(
const BaseT &
base,
size_t n) {
1349 return n == 0 ?
base : DerivedT::offset_base(
base, n);
1365template <
typename OtherT,
typename DerivedT,
typename BaseT,
typename T,
1366 typename PointerT,
typename ReferenceT>
1369 const OtherT &rhs) {
1370 return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
1373template <
typename OtherT,
typename DerivedT,
typename BaseT,
typename T,
1374 typename PointerT,
typename ReferenceT>
1377 const OtherT &rhs) {
1378 return !(lhs == rhs);
1389template <
typename DerivedT,
typename BaseT,
typename T,
1390 typename PointerT =
T *,
typename ReferenceT =
T &>
1393 DerivedT, std::pair<BaseT, ptrdiff_t>, T, PointerT, ReferenceT> {
1397 DerivedT,
std::pair<BaseT,
ptrdiff_t>,
T, PointerT, ReferenceT>(
1400 DerivedT, std::pair<BaseT, ptrdiff_t>,
T, PointerT,
1410 static std::pair<BaseT, ptrdiff_t>
1414 return std::make_pair(
base.first,
base.second + index);
1420 return DerivedT::dereference(
base.first,
base.second + index);
1433 using type = std::conditional_t<std::is_reference<EltTy>::value, FirstTy,
1434 std::remove_reference_t<FirstTy>>;
1440 using EltTy =
decltype((*std::begin(c)));
1443 EltTy,
decltype((elt.first))>::type {
1450 using EltTy =
decltype((*std::begin(c)));
1452 std::forward<ContainerTy>(c),
1455 decltype((elt.second))>::type {
1469 return std::less<>()(std::get<0>(lhs), std::get<0>(rhs));
1478 return std::less<>()(std::get<1>(lhs), std::get<1>(rhs));
1484template<
typename FuncTy>
1488 template <
typename T>
1489 decltype(
auto)
operator()(
const T &lhs,
const T &rhs)
const {
1490 return func(lhs.first, rhs.first);
1502template <
typename HeadT,
typename... TailTs>
1508 using Visitor<TailTs...>::operator();
1546template <
typename... CallableTs>
1548 return detail::Visitor<CallableTs...>(std::forward<CallableTs>(Callables)...);
1557template <
class Iterator,
class RNG>
1562 typename std::iterator_traits<Iterator>::difference_type difference_type;
1563 for (
auto size = last - first;
size > 1; ++first, (void)--
size) {
1564 difference_type offset =
g() %
size;
1567 if (offset != difference_type(0))
1568 std::iter_swap(first, first + offset);
1575 if (std::less<T>()(*
reinterpret_cast<const T*
>(P1),
1576 *
reinterpret_cast<const T*
>(P2)))
1578 if (std::less<T>()(*
reinterpret_cast<const T*
>(P2),
1579 *
reinterpret_cast<const T*
>(P1)))
1588 (
const void*,
const void*) {
1589 return array_pod_sort_comparator<T>;
1592#ifdef EXPENSIVE_CHECKS
1595inline unsigned presortShuffleEntropy() {
1596 static unsigned Result(std::random_device{}());
1600template <
class IteratorTy>
1601inline void presortShuffle(IteratorTy Start, IteratorTy
End) {
1602 std::mt19937 Generator(presortShuffleEntropy());
1623template<
class IteratorTy>
1627 auto NElts =
End - Start;
1628 if (NElts <= 1)
return;
1629#ifdef EXPENSIVE_CHECKS
1630 detail::presortShuffle<IteratorTy>(Start,
End);
1635template <
class IteratorTy>
1637 IteratorTy Start, IteratorTy
End,
1639 const typename std::iterator_traits<IteratorTy>::value_type *,
1640 const typename std::iterator_traits<IteratorTy>::value_type *)) {
1643 auto NElts =
End - Start;
1644 if (NElts <= 1)
return;
1645#ifdef EXPENSIVE_CHECKS
1646 detail::presortShuffle<IteratorTy>(Start,
End);
1648 qsort(&*Start, NElts,
sizeof(*Start),
1649 reinterpret_cast<int (*)(
const void *,
const void *)
>(Compare));
1653template <
typename T>
1658 std::is_trivially_copyable<typename std::iterator_traits<T>::value_type>>;
1663template <
typename IteratorTy>
1664inline void sort(IteratorTy Start, IteratorTy
End) {
1670#ifdef EXPENSIVE_CHECKS
1671 detail::presortShuffle<IteratorTy>(Start,
End);
1673 std::sort(Start,
End);
1677template <
typename Container>
inline void sort(Container &&
C) {
1681template <
typename IteratorTy,
typename Compare>
1682inline void sort(IteratorTy Start, IteratorTy
End, Compare Comp) {
1683#ifdef EXPENSIVE_CHECKS
1684 detail::presortShuffle<IteratorTy>(Start,
End);
1686 std::sort(Start,
End, Comp);
1689template <
typename Container,
typename Compare>
1690inline void sort(Container &&
C, Compare Comp) {
1696template <
typename R>
1699 std::is_base_of<std::random_access_iterator_tag,
1700 typename std::iterator_traits<
decltype(
1702 void> * =
nullptr) {
1703 return std::distance(
Range.begin(),
Range.end());
1707template <
typename Range>
1709 decltype(
adl_size(std::declval<Range &>()));
1711template <
typename Range>
1723 if constexpr (detail::HasFreeFunctionSize<R>)
1731template <
typename R,
typename UnaryFunction>
1738template <
typename R,
typename UnaryPredicate>
1745template <
typename R,
typename UnaryPredicate>
1752template <
typename R,
typename UnaryPredicate>
1759template <
typename R,
typename T>
auto find(R &&
Range,
const T &Val) {
1765template <
typename R,
typename UnaryPredicate>
1770template <
typename R,
typename UnaryPredicate>
1777template <
typename R,
typename UnaryPredicate>
1784template <
typename R,
typename OutputIt,
typename UnaryPredicate>
1794template <
typename T,
typename R,
typename Predicate>
1798 if (
T *PRC =
P(
A, AllowRepeats)) {
1800 if (!AllowRepeats || PRC != RC)
1818template <
typename T,
typename R,
typename Predicate>
1820 bool AllowRepeats =
false) {
1823 std::pair<T *, bool> PRC =
P(
A, AllowRepeats);
1825 assert(PRC.first ==
nullptr &&
1826 "Inconsistent return values in find_singleton_nested.");
1831 if (!AllowRepeats || PRC.first != RC)
1832 return {
nullptr,
true};
1840template <
typename R,
typename OutputIt>
1847template <
typename R,
typename OutputIt,
typename UnaryPredicate,
typename T>
1849 const T &NewValue) {
1856template <
typename R,
typename OutputIt,
typename T>
1858 const T &NewValue) {
1865template <
typename R,
typename T>
1872template <
typename R,
typename OutputIt>
1878template <
typename Range,
typename Element>
1880 decltype(std::declval<Range &>().contains(std::declval<const Element &>()));
1882template <
typename Range,
typename Element>
1886template <
typename Range,
typename Element>
1888 decltype(std::declval<Range &>().find(std::declval<const Element &>()) !=
1889 std::declval<Range &>().end());
1891template <
typename Range,
typename Element>
1902template <
typename R,
typename E>
1904 if constexpr (detail::HasMemberContains<R, E>)
1906 else if constexpr (detail::HasMemberFind<R, E>)
1915template <
typename T,
typename E>
1918 for (
const T &V : Set)
1938template <
typename R,
typename E>
auto count(R &&
Range,
const E &Element) {
1944template <
typename R,
typename UnaryPredicate>
1951template <
typename R,
typename OutputIt,
typename UnaryFunction>
1958template <
typename R,
typename UnaryPredicate>
1967 std::forward<T>(
Value));
1970template <
typename R,
typename T,
typename Compare>
1973 std::forward<T>(
Value),
C);
1980 std::forward<T>(
Value));
1983template <
typename R,
typename T,
typename Compare>
1986 std::forward<T>(
Value),
C);
1993 std::forward<T>(
Value));
1996template <
typename R,
typename T,
typename Compare>
1999 std::forward<T>(
Value),
C);
2031template <
typename R1,
typename R2>
auto mismatch(R1 &&Range1,
R2 &&Range2) {
2036template <
typename R>
2041template <
typename R,
typename Compare>
2048template <
typename R,
typename Predicate,
2049 typename Val =
decltype(*
adl_begin(std::declval<R>()))>
2054template<
typename Range,
typename Predicate>
2067template <
typename L,
typename R>
bool equal(L &&LRange, R &&RRange) {
2072template <
typename L,
typename R,
typename BinaryPredicate>
2073bool equal(L &&LRange, R &&RRange, BinaryPredicate
P) {
2082 return Begin ==
End || std::equal(std::next(Begin),
End, Begin);
2087template <
typename T>
bool all_equal(std::initializer_list<T> Values) {
2088 return all_equal<std::initializer_list<T>>(std::move(Values));
2098template <
typename Container,
typename UnaryPredicate>
2106template <
typename Container,
typename ValueType>
2108 C.erase(std::remove(
C.begin(),
C.end(), V),
C.end());
2114template <
typename Container,
typename Range>
2120template <
typename Container,
typename... Args>
2124 ((void)
C.insert(
C.end(), std::forward<Args>(Values)), ...);
2129template<
typename Container,
typename RandomAccessIterator>
2130void replace(Container &Cont,
typename Container::iterator ContIt,
2131 typename Container::iterator ContEnd, RandomAccessIterator ValIt,
2132 RandomAccessIterator ValEnd) {
2134 if (ValIt == ValEnd) {
2135 Cont.erase(ContIt, ContEnd);
2137 }
else if (ContIt == ContEnd) {
2138 Cont.insert(ContIt, ValIt, ValEnd);
2141 *ContIt++ = *ValIt++;
2147template<
typename Container,
typename Range = std::initializer_list<
2148 typename Container::value_type>>
2149void replace(Container &Cont,
typename Container::iterator ContIt,
2150 typename Container::iterator ContEnd,
Range R) {
2151 replace(Cont, ContIt, ContEnd, R.begin(), R.end());
2164template <
typename ForwardIterator,
typename UnaryFunctor,
2165 typename NullaryFunctor,
2166 typename = std::enable_if_t<
2167 !std::is_constructible<StringRef, UnaryFunctor>::value &&
2168 !std::is_constructible<StringRef, NullaryFunctor>::value>>
2169inline void interleave(ForwardIterator begin, ForwardIterator end,
2170 UnaryFunctor each_fn, NullaryFunctor between_fn) {
2175 for (; begin != end; ++begin) {
2181template <
typename Container,
typename UnaryFunctor,
typename NullaryFunctor,
2182 typename = std::enable_if_t<
2183 !std::is_constructible<StringRef, UnaryFunctor>::value &&
2184 !std::is_constructible<StringRef, NullaryFunctor>::value>>
2186 NullaryFunctor between_fn) {
2191template <
typename Container,
typename UnaryFunctor,
typename StreamT,
2192 typename T = detail::ValueOfRange<Container>>
2193inline void interleave(
const Container &c, StreamT &os, UnaryFunctor each_fn,
2197template <
typename Container,
typename StreamT,
2198 typename T = detail::ValueOfRange<Container>>
2202 c, os, [&](
const T &a) { os << a; }, separator);
2205template <
typename Container,
typename UnaryFunctor,
typename StreamT,
2206 typename T = detail::ValueOfRange<Container>>
2208 UnaryFunctor each_fn) {
2211template <
typename Container,
typename StreamT,
2212 typename T = detail::ValueOfRange<Container>>
2227template<
typename First,
typename Second>
2230 return std::hash<First>()(
P.first) * 31 + std::hash<Second>()(
P.second);
2245 return func(*lhs, *rhs);
2254template <
typename... Iters>
2268template <
typename... Iters>
2270 EnumeratorTupleType<Iters...>, Iters...> {
2271 static_assert(
sizeof...(Iters) >= 2,
"Expected at least two iteratees");
2273 Iters...>::zip_common;
2276 return std::get<1>(this->
iterators) == std::get<1>(
Other.iterators);
2281 static constexpr std::size_t NumRefs =
sizeof...(Refs);
2282 static_assert(NumRefs != 0);
2284 static constexpr std::size_t NumValues = NumRefs + 1;
2293 :
Idx(
Index), Storage(
std::forward<Refs>(Rs)...) {}
2302 if constexpr (NumRefs == 1)
2303 return std::get<0>(Storage);
2309 template <std::
size_t I,
typename = std::enable_if_t<I == 0>>
2316 template <std::
size_t I,
typename = std::enable_if_t<I != 0>>
2321 return std::get<
I - 1>(Result.Storage);
2324 template <
typename... Ts>
2326 const std::tuple<std::size_t, Ts...> &
Other) {
2327 static_assert(NumRefs ==
sizeof...(Ts),
"Size mismatch");
2328 if (Result.Idx != std::get<0>(
Other))
2330 return Result.is_value_equal(
Other, std::make_index_sequence<NumRefs>{});
2334 template <
typename Tuple, std::size_t...
Idx>
2335 bool is_value_equal(
const Tuple &
Other, std::index_sequence<Idx...>)
const {
2336 return ((std::get<Idx>(Storage) == std::get<Idx + 1>(
Other)) && ...);
2347 mutable range_reference_tuple Storage;
2352 std::random_access_iterator_tag, std::size_t> {
2366 return Index - R.Index;
2377 return Lhs.Index == Rhs.Index;
2381 return Lhs.Index < Rhs.Index;
2447template <
typename FirstRange,
typename... RestRanges>
2449 if constexpr (
sizeof...(Rest) != 0) {
2458 FirstRange, RestRanges...>;
2460 std::forward<RestRanges>(Rest)...);
2465template <
typename Predicate,
typename... Args>
2468 auto it = z.begin();
2471 if (!std::apply([&](
auto &&...
args) {
return P(
args...); }, *it))
2475 return it.all_equals(end);
2480template <
typename... ArgsThenPredicate,
size_t... InputIndexes>
2482 std::tuple<ArgsThenPredicate...> argsThenPredicate,
2483 std::index_sequence<InputIndexes...>) {
2484 auto constexpr OutputIndex =
2485 std::tuple_size<
decltype(argsThenPredicate)>
::value - 1;
2487 std::get<InputIndexes>(argsThenPredicate)...);
2495template <
typename... ArgsAndPredicate>
2498 std::forward_as_tuple(argsAndPredicate...),
2499 std::make_index_sequence<
sizeof...(argsAndPredicate) - 1>{});
2505template <
typename IterTy,
2506 typename Pred =
bool (*)(
const decltype(*std::declval<IterTy>()) &)>
2508 IterTy &&Begin, IterTy &&
End,
unsigned N,
2509 Pred &&ShouldBeCounted =
2510 [](
const decltype(*std::declval<IterTy>()) &) {
return true; },
2512 !std::is_base_of<std::random_access_iterator_tag,
2513 typename std::iterator_traits<std::remove_reference_t<
2514 decltype(Begin)>>::iterator_category>
::value,
2515 void> * =
nullptr) {
2516 for (;
N; ++Begin) {
2519 N -= ShouldBeCounted(*Begin);
2521 for (; Begin !=
End; ++Begin)
2522 if (ShouldBeCounted(*Begin))
2530template <
typename IterTy,
2531 typename Pred =
bool (*)(
const decltype(*std::declval<IterTy>()) &)>
2533 IterTy &&Begin, IterTy &&
End,
unsigned N,
2534 Pred &&ShouldBeCounted =
2535 [](
const decltype(*std::declval<IterTy>()) &) {
return true; },
2537 !std::is_base_of<std::random_access_iterator_tag,
2538 typename std::iterator_traits<std::remove_reference_t<
2539 decltype(Begin)>>::iterator_category>
::value,
2540 void> * =
nullptr) {
2541 for (;
N; ++Begin) {
2544 N -= ShouldBeCounted(*Begin);
2551template <
typename IterTy,
2552 typename Pred =
bool (*)(
const decltype(*std::declval<IterTy>()) &)>
2554 IterTy &&Begin, IterTy &&
End,
unsigned N,
2555 Pred &&ShouldBeCounted = [](
const decltype(*std::declval<IterTy>()) &) {
2558 assert(
N != std::numeric_limits<unsigned>::max());
2563template <
typename ContainerTy>
bool hasNItems(ContainerTy &&
C,
unsigned N) {
2568template <
typename ContainerTy>
2574template <
typename ContainerTy>
2596template <
typename T>
2602template <
typename... Refs>
2603struct tuple_size<
llvm::detail::enumerator_result<Refs...>>
2604 : std::integral_constant<std::size_t, sizeof...(Refs)> {};
2606template <std::size_t
I,
typename... Refs>
2607struct tuple_element<
I,
llvm::detail::enumerator_result<Refs...>>
2608 : std::tuple_element<I, std::tuple<Refs...>> {};
2610template <std::size_t
I,
typename... Refs>
2611struct tuple_element<
I,
const llvm::detail::enumerator_result<Refs...>>
2612 : 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
concat_iterator(RangeTs &&... Ranges)
Constructs an iterator from a sequence of ranges.
reference_type operator*() const
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)
Provide wrappers to std::min_element which take ranges instead of having to pass begin/end explicitly...
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'.
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
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 mismatch(R1 &&Range1, R2 &&Range2)
Provide wrappers to std::mismatch 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)...
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...
void replace(R &&Range, const T &OldValue, const T &NewValue)
Provide wrappers to std::replace 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)
Provide wrappers to std::max_element which take ranges instead of having to pass begin/end explicitly...
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 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.