14#include "CoreMinimal.h"
18#include "range/v3/all.hpp"
27 decltype(
auto)
Literal(std::initializer_list<T>&& input) {
return FWD(input); }
30 template <CRangeMember... Ranges>
31 auto Zip(Ranges&&...right)
33 return ranges::make_pipeable([&](
auto&& left)
35 return ranges::views::zip(left,
FWD(right)...);
40 template <CRangeMember... Ranges>
43 return ranges::make_pipeable([&](
auto&& left)
45 return ranges::views::concat(left,
FWD(right)...);
50 template <CRangeMember Input>
59 return ranges::make_pipeable([](
auto&& left){
return IsEmpty(left); });
67 decltype(
auto)
First(Input&& range, Value&& def)
69 return IsEmpty(range) ? def : *range.begin();
73 FORCEINLINE
auto First(
auto&& def)
75 return ranges::make_pipeable([&](
auto&& left){
return First(left, def); });
88 return IsEmpty(range) ? Value{} : *range.begin();
97 return ranges::make_pipeable([&](
auto&& left){
return FirstOrDefault(left); });
113 template <CRangeMember Left, CRangeMember Right>
115 bool MatchOrdered(Left&& left, Right&& right,
bool matchOnlyBeginning =
false)
120 if (!matchOnlyBeginning &&
size(left) !=
size(right))
123 auto leftIt = left.begin();
124 auto rightIt = right.begin();
128 return matchOnlyBeginning || (
132 if (*leftIt != *rightIt)
return false;
138 template <CRangeMember Left,
typename Value>
139 requires CCoreHalfEqualityComparable<Value, TRangeElementType<Left>>
140 bool MatchOrdered(Left&& left, std::initializer_list<Value>&& right,
bool matchOnlyBeginning =
false)
157 template <CRangeMember Right>
160 return ranges::make_pipeable([&](
auto&& left){
return MatchOrdered(left, right, matchOnlyBeginning); });
163 template <
typename Value>
164 auto MatchOrdered(std::initializer_list<Value>&& right,
bool matchOnlyBeginning =
false)
166 return ranges::make_pipeable([&](
auto&& left){
return MatchOrdered(left, right, matchOnlyBeginning); });
169 template <CFunctionLike Predicate>
172 return ranges::make_pipeable([&](
auto&& left){
return ranges::all_of(left, pred); });
175 template <CFunctionLike Predicate>
178 return ranges::make_pipeable([&](
auto&& left){
return ranges::any_of(left, pred); });
183 return ranges::views::filter([]<CValidable T>(T&& item)
215 template <CFunctionLike Transform, CRangeOfTuplesCompatibleWithFunction<Transform> Left>
219 return ranges::views::transform(
FWD(left), [tr](Tuple
const& tuple)
249 template <CFunctionLike Transform>
284 template <CFunctionLike Predicate, CRangeOfTuplesCompatibleWithFunction<Predicate> Left>
288 return ranges::views::transform(
FWD(left), [predicate](Tuple
const& tuple)
318 template <CFunctionLike Predicate>
327 template <
size_t ItemIndex, CRangeOfTuples Range>
331 return ranges::views::transform(
FWD(left), [](Tuple
const& tuple)
337 template <
size_t ItemIndex>
Use this header and Start.h in tandem to include third-party library headers which may not tolerate U...
#define FWD(...)
Shorten forwarding expression with this macro so one may not need to specify explicit type.
size_t size(TArray< T, A > const &r)
Use this header and End.h in tandem to include third-party library headers which may not tolerate Unr...
bool TestValid(T &&input)
Attempt to test the input object validity through various methods.
TFunction_Return< Function > InvokeWithTuple(Function &&function, Tuple &&arguments)
A clone of std::apply for Unreal, STL and RangeV3 tuples which also supports function pointers.
decltype(auto) First(Input &&range, Value &&def)
Get's the first element of a range or return a provided default value. Same as *r....
bool MatchOrdered(Left &&left, Right &&right, bool matchOnlyBeginning=false)
Return true if input ranges match their values and their order.
auto Concat(Ranges &&...right)
pipeable version of ranges::views::concat
FORCEINLINE auto GetKeys()
FORCEINLINE auto GetValues()
FORCEINLINE auto IsEmpty()
Check if range is empty.
auto AnyOf(Predicate &&pred)
bool IteratorEquals(L const &l, R const &r)
FORCEINLINE auto FilterValid()
auto Zip(Ranges &&...right)
pipeable version of ranges::views::zip
TIteratorElementType< decltype(DeclVal< T >().begin())> TRangeElementType
return a range's associated content type determined by dereferencing their iterator.
auto AllOf(Predicate &&pred)
auto TransformTuple(Left &&left, Transform &&tr)
Transform a range of tuples with structured binding function arguments, so range transformations shou...
FORCEINLINE auto FirstOrDefault()
Get's the first element of a range or return the default value for the element type....
decltype(auto) Literal(std::initializer_list< T > &&input)
Make an initializer list compatible with range API's.
auto FilterTuple(Left &&left, Predicate &&predicate)
Filter a range of tuples with structured binding function arguments, so filter predicates shouldn't b...
decltype(auto) GetItem(T &&tuple)