MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::Range Namespace Reference

Namespaces

namespace  Detail
 

Data Structures

struct  FExtendedIteratorPolicy
 Extra settings for TExtendedIterator wrapper. More...
 
struct  FRangeStringFormatOptions
 
struct  FTempStringIterator
 Allows range-v3 and std::ranges to iterate over temporary string objects and keep the string alive during view and action operators. More...
 
class  OutputTo
 Render a range to an already existing container. More...
 
class  OutputToMap
 Output a range of tuples or range of ranges with at least 2 elements to an already existing TMap. More...
 
class  RenderAs
 Render a range as the given container. More...
 
class  RenderAsMap
 Render a range of tuples or range of ranges with at least 2 elements as a TMap. More...
 
struct  TExtendedIterator
 Unreal's own iterators are not STL compliant (they are only compatible with range-for loops) so they cannot be used with more advanced STL algorithms or other third-party libraries which may expect the full iterator interface compatibility. For that TExtendedIterator fills in the missing components and wraps Unreal iterators to be fully STL iterator compliant. More...
 
struct  TIteratorCompare_Struct
 
struct  TIteratorCompare_Struct< T >
 
struct  TIteratorComputeDistance_Struct
 
struct  TIteratorComputeDistance_Struct< T >
 
struct  TIteratorDifference_Struct
 
struct  TIteratorDifference_Struct< T >
 
struct  TIteratorJumpBackward_Struct
 
struct  TIteratorJumpBackward_Struct< T >
 
struct  TIteratorJumpForward_Struct
 
struct  TIteratorJumpForward_Struct< T >
 

Concepts

concept  CHasEquals
 
concept  CHasNotEquals
 
concept  CBasicForwardIteratorBase
 The most basic minimal iterator which can only proceed forward one element at a time.
 
concept  CBasicForwardIterator
 
concept  CHasMemberAccessOperator
 
concept  CBasicBidirectionalIterator
 Basic minimal iterator which can only proceed forward or backward one element at a time.
 
concept  CJumpForwardIterator
 An iterator type which can natively proceed forward in arbitrarily large steps.
 
concept  CJumpForwardPlusIterator
 An iterator type which can natively proceed forward in arbitrarily large steps and exposes a + operator.
 
concept  CRandomAccessIterator
 An iterator type which can natively seek its associated content in arbitrarily large steps.
 
concept  CRandomAccessPlusMinusIterator
 An iterator type which can natively seek its associated content in arbitrarily large steps and exposes +- operators.
 
concept  CIsIteratorStep
 Constraint given iterator to its best stepping capability.
 
concept  CIsIteratorDirection
 Constraint given iterator to its best directional capability.
 
concept  CIteratorFeature
 Constraint given iterator to its best capabilies both in stepping and in direction.
 
concept  CUnrealRange
 
concept  CStdDistanceCompatible
 
concept  CHasGetIndex
 
concept  CHasElementIndex
 
concept  CIteratorComparable
 
concept  CCountableRange
 
concept  CRangeOfTuples
 
concept  CRangeOfTuplesCompatibleWithFunction
 

Typedefs

template<typename T >
using TIteratorCategory
 Assume an STL iterator category from input iterator.
 
template<CBasicForwardIterator T>
using TIteratorElementType = std::decay_t<decltype(*DeclVal<T>())>
 return the iterator's associated content type when they're dereferenced.
 
template<CRangeMember T>
using TRangeElementType = TIteratorElementType<decltype(DeclVal<T>().begin())>
 return a range's associated content type determined by dereferencing their iterator.
 
template<typename T >
using TIteratorDifference = typename TIteratorDifference_Struct<T>::Type
 return a difference type for given iterator.
 

Enumerations

enum class  EIteratorDirection { NotIterator , Forward , Bidirectional }
 
enum class  EIteratorStep { NotIterator , Single , Jump , JumpBinaryOperators }
 

Functions

template<typename L , typename R >
bool IteratorEquals (L const &l, R const &r)
 
FORCEINLINE auto Separator (FString const &separator)
 Specify a separator sequence for a range when converting it to a string.
 
FORCEINLINE auto Enclosure (FString const &start, FString const &end)
 Specify a start and an end sequence enclosing this range when converting it to a string.
 
FORCEINLINE auto NoSeparator ()
 Don't use a separator when this range is rendered to a string.
 
FORCEINLINE auto NoEnclosure ()
 Don't enclose this range in anything when it's rendered to a string.
 
FORCEINLINE auto NoDecorators ()
 Don't insert anything else than the contents of the input range when that is rendered as a string just append each item one after the other.
 
template<CRangeMember Range>
FString RenderAsString (Range &&range)
 Render an input range as a string.
 
FORCEINLINE auto RenderAsString ()
 
template<typename T >
decltype(auto) Literal (std::initializer_list< T > &&input)
 Make an initializer list compatible with range API's.
 
template<CRangeMember... Ranges>
auto Zip (Ranges &&...right)
 pipeable version of ranges::views::zip
 
template<CRangeMember... Ranges>
auto Concat (Ranges &&...right)
 pipeable version of ranges::views::concat
 
template<CRangeMember Input>
bool IsEmpty (Input &&range)
 Check if range is empty.
 
FORCEINLINE auto IsEmpty ()
 Check if range is empty.
 
template<CRangeMember Input, typename Value = TRangeElementType<Input>>
decltype(auto) First (Input &&range, Value &&def)
 Get's the first element of a range or return a provided default value. Same as *r.begin() but safer.
 
FORCEINLINE auto First (auto &&def)
 Get's the first element of a range or return a provided default value. Same as *r.begin() but safer.
 
template<CRangeMember Input, typename Value = TRangeElementType<Input>>
decltype(auto) FirstOrDefault (Input &&range)
 Get's the first element of a range or return the default value for the element type. Same as *r.begin() but safer.
 
FORCEINLINE auto FirstOrDefault ()
 Get's the first element of a range or return the default value for the element type. Same as *r.begin() but safer.
 
template<CRangeMember Left, CRangeMember Right>
requires CCoreHalfEqualityComparable<TRangeElementType<Left>, TRangeElementType<Right>>
bool MatchOrdered (Left &&left, Right &&right, bool matchOnlyBeginning=false)
 Return true if input ranges match their values and their order.
 
template<CRangeMember Left, typename Value >
requires CCoreHalfEqualityComparable<Value, TRangeElementType<Left>>
bool MatchOrdered (Left &&left, std::initializer_list< Value > &&right, bool matchOnlyBeginning=false)
 
template<CRangeMember Right>
auto MatchOrdered (Right &&right, bool matchOnlyBeginning=false)
 Return true if input ranges match their values and their order.
 
template<typename Value >
auto MatchOrdered (std::initializer_list< Value > &&right, bool matchOnlyBeginning=false)
 
template<CFunctionLike Predicate>
auto AllOf (Predicate &&pred)
 
template<CFunctionLike Predicate>
auto AnyOf (Predicate &&pred)
 
FORCEINLINE auto FilterValid ()
 
template<CFunctionLike Transform, CRangeOfTuplesCompatibleWithFunction< Transform > Left>
auto TransformTuple (Left &&left, Transform &&tr)
 Transform a range of tuples with structured binding function arguments, so range transformations shouldn't bother with the actual type of the tuple.
 
template<CFunctionLike Transform>
auto TransformTuple (Transform &&tr)
 Transform a range of tuples with structured binding function arguments, so range transformations shouldn't bother with the actual type of the tuple.
 
template<CFunctionLike Predicate, CRangeOfTuplesCompatibleWithFunction< Predicate > Left>
auto FilterTuple (Left &&left, Predicate &&predicate)
 Filter a range of tuples with structured binding function arguments, so filter predicates shouldn't bother with the actual type of the tuple.
 
template<CFunctionLike Predicate>
auto FilterTuple (Predicate &&predicate)
 Filter a range of tuples with structured binding function arguments, so filter predicates shouldn't bother with the actual type of the tuple.
 
template<size_t ItemIndex, CRangeOfTuples Range>
auto SelectTupleItem (Range &&left)
 
template<size_t ItemIndex>
auto SelectTupleItem ()
 
FORCEINLINE auto GetKeys ()
 
FORCEINLINE auto GetValues ()
 

Variables

template<typename T >
constexpr EIteratorDirection TIteratorDirection
 Get the direction given iterator is capable of.
 
template<typename T >
constexpr EIteratorStep TIteratorStep
 Get the maximum steps the given iterator can be seeking with.
 
template<typename T >
constexpr TIteratorJumpForward_Struct< T > TIteratorJumpForward
 
template<typename T >
constexpr TIteratorJumpBackward_Struct< T > TIteratorJumpBackward
 
template<typename T >
constexpr TIteratorCompare_Struct< T > TIteratorCompare
 
template<typename T >
constexpr TIteratorComputeDistance_Struct< T > TIteratorComputeDistance
 

Typedef Documentation

◆ TIteratorCategory

template<typename T >
using Mcro::Range::TIteratorCategory
Initial value:
std::conditional_t<
std::random_access_iterator_tag,
std::conditional_t<
std::bidirectional_iterator_tag,
std::conditional_t<
std::forward_iterator_tag,
std::input_iterator_tag
>
>
>
Basic minimal iterator which can only proceed forward or backward one element at a time.
Definition Concepts.h:66
An iterator type which can natively seek its associated content in arbitrarily large steps.
Definition Concepts.h:78

Assume an STL iterator category from input iterator.

Definition at line 119 of file Concepts.h.

◆ TIteratorDifference

template<typename T >
using Mcro::Range::TIteratorDifference = typename TIteratorDifference_Struct<T>::Type

return a difference type for given iterator.

Definition at line 141 of file Iterators.h.

◆ TIteratorElementType

template<CBasicForwardIterator T>
using Mcro::Range::TIteratorElementType = std::decay_t<decltype(*DeclVal<T>())>

return the iterator's associated content type when they're dereferenced.

Definition at line 157 of file Concepts.h.

◆ TRangeElementType

template<CRangeMember T>
using Mcro::Range::TRangeElementType = TIteratorElementType<decltype(DeclVal<T>().begin())>

return a range's associated content type determined by dereferencing their iterator.

Definition at line 161 of file Concepts.h.

Enumeration Type Documentation

◆ EIteratorDirection

Enumerator
NotIterator 
Forward 
Bidirectional 

Definition at line 24 of file Concepts.h.

◆ EIteratorStep

enum class Mcro::Range::EIteratorStep
strong
Enumerator
NotIterator 
Single 
Jump 
JumpBinaryOperators 

Definition at line 30 of file Concepts.h.

Function Documentation

◆ AllOf()

template<CFunctionLike Predicate>
auto Mcro::Range::AllOf ( Predicate && pred)

Definition at line 170 of file Views.h.

◆ AnyOf()

template<CFunctionLike Predicate>
auto Mcro::Range::AnyOf ( Predicate && pred)

Definition at line 176 of file Views.h.

◆ Concat()

template<CRangeMember... Ranges>
auto Mcro::Range::Concat ( Ranges &&... right)

pipeable version of ranges::views::concat

Definition at line 41 of file Views.h.

◆ Enclosure()

FORCEINLINE auto Mcro::Range::Enclosure ( FString const & start,
FString const & end )

Specify a start and an end sequence enclosing this range when converting it to a string.

Definition at line 75 of file Conversion.h.

◆ FilterTuple() [1/2]

template<CFunctionLike Predicate, CRangeOfTuplesCompatibleWithFunction< Predicate > Left>
auto Mcro::Range::FilterTuple ( Left && left,
Predicate && predicate )

Filter a range of tuples with structured binding function arguments, so filter predicates shouldn't bother with the actual type of the tuple.

For example:

int32 size = 4;
// | highFreq | lowFreq
namespace rv = ranges::views; // V V
auto things = rv::cartesian(rv::indices(0, size), rv::indices(0, size))
| FilterTuple([size](int32 highFreq, int32 lowFreq)
{
return highFreq == 2;
})
;
FMT_LOG(LogTemp, Display, "Things: {0}", things);
//-> Things: [(2, 0), (2, 1), (2, 2), (2, 3)]
#define FMT_LOG(categoryName, verbosity, format,...)
Similar to UE_LOGFMT, but implemented via MCRO's own _FMT macro. So it's more convenient to pass form...
Definition FmtMacros.h:246
size_t size(TArray< T, A > const &r)
Definition Range.h:101
auto FilterTuple(Left &&left, Predicate &&predicate)
Filter a range of tuples with structured binding function arguments, so filter predicates shouldn't b...
Definition Views.h:285
Template Parameters
PredicateA transformation function type with signature compatible with input tuple.
LeftThe type of the range of tuples
Parameters
leftThe range of tuples
predicateA transformation function with signature compatible with input tuple.
Returns
Range with transformed elements

Definition at line 285 of file Views.h.

◆ FilterTuple() [2/2]

template<CFunctionLike Predicate>
auto Mcro::Range::FilterTuple ( Predicate && predicate)

Filter a range of tuples with structured binding function arguments, so filter predicates shouldn't bother with the actual type of the tuple.

For example:

int32 size = 4;
// | highFreq | lowFreq
namespace rv = ranges::views; // V V
auto things = rv::cartesian(rv::indices(0, size), rv::indices(0, size))
| FilterTuple([size](int32 highFreq, int32 lowFreq)
{
return highFreq == 2;
})
;
FMT_LOG(LogTemp, Display, "Things: {0}", things);
//-> Things: [(2, 0), (2, 1), (2, 2), (2, 3)]
Template Parameters
PredicateA filter predicate function type with signature compatible with input tuple.
Parameters
predicateA filter predicate function with signature compatible with input tuple.
Returns
Range with transformed elements

Definition at line 319 of file Views.h.

◆ FilterValid()

FORCEINLINE auto Mcro::Range::FilterValid ( )

Definition at line 181 of file Views.h.

◆ First() [1/2]

FORCEINLINE auto Mcro::Range::First ( auto && def)

Get's the first element of a range or return a provided default value. Same as *r.begin() but safer.

Definition at line 73 of file Views.h.

◆ First() [2/2]

template<CRangeMember Input, typename Value = TRangeElementType<Input>>
decltype(auto) Mcro::Range::First ( Input && range,
Value && def )

Get's the first element of a range or return a provided default value. Same as *r.begin() but safer.

Definition at line 67 of file Views.h.

◆ FirstOrDefault() [1/2]

FORCEINLINE auto Mcro::Range::FirstOrDefault ( )

Get's the first element of a range or return the default value for the element type. Same as *r.begin() but safer.

Definition at line 95 of file Views.h.

◆ FirstOrDefault() [2/2]

template<CRangeMember Input, typename Value = TRangeElementType<Input>>
decltype(auto) Mcro::Range::FirstOrDefault ( Input && range)

Get's the first element of a range or return the default value for the element type. Same as *r.begin() but safer.

Definition at line 86 of file Views.h.

◆ GetKeys()

FORCEINLINE auto Mcro::Range::GetKeys ( )

Definition at line 346 of file Views.h.

◆ GetValues()

FORCEINLINE auto Mcro::Range::GetValues ( )

Definition at line 347 of file Views.h.

◆ IsEmpty() [1/2]

FORCEINLINE auto Mcro::Range::IsEmpty ( )

Check if range is empty.

Definition at line 57 of file Views.h.

◆ IsEmpty() [2/2]

template<CRangeMember Input>
bool Mcro::Range::IsEmpty ( Input && range)

Check if range is empty.

Definition at line 51 of file Views.h.

◆ IteratorEquals()

template<typename L , typename R >
bool Mcro::Range::IteratorEquals ( L const & l,
R const & r )

Definition at line 45 of file Concepts.h.

◆ Literal()

template<typename T >
decltype(auto) Mcro::Range::Literal ( std::initializer_list< T > && input)

Make an initializer list compatible with range API's.

Definition at line 27 of file Views.h.

◆ MatchOrdered() [1/4]

template<CRangeMember Left, CRangeMember Right>
requires CCoreHalfEqualityComparable<TRangeElementType<Left>, TRangeElementType<Right>>
bool Mcro::Range::MatchOrdered ( Left && left,
Right && right,
bool matchOnlyBeginning = false )

Return true if input ranges match their values and their order.

This runs in O(N) time when result is true, unless both input ranges are CCountableRange, matchOnlyBeginning is false and the two input ranges have different size.

Parameters
leftInput range
rightRange to compare with
matchOnlyBeginningBy default MatchOrdered returns false for ranges with different lengths

Definition at line 115 of file Views.h.

◆ MatchOrdered() [2/4]

template<CRangeMember Left, typename Value >
requires CCoreHalfEqualityComparable<Value, TRangeElementType<Left>>
bool Mcro::Range::MatchOrdered ( Left && left,
std::initializer_list< Value > && right,
bool matchOnlyBeginning = false )

Definition at line 140 of file Views.h.

◆ MatchOrdered() [3/4]

template<CRangeMember Right>
auto Mcro::Range::MatchOrdered ( Right && right,
bool matchOnlyBeginning = false )

Return true if input ranges match their values and their order.

This runs in O(N) time when result is true, unless both input ranges are CCountableRange, matchOnlyBeginning is false and the two input ranges have different size.

Parameters
rightRange to compare with
matchOnlyBeginningBy default MatchOrdered returns false for ranges with different lengths

Definition at line 158 of file Views.h.

◆ MatchOrdered() [4/4]

template<typename Value >
auto Mcro::Range::MatchOrdered ( std::initializer_list< Value > && right,
bool matchOnlyBeginning = false )

Definition at line 164 of file Views.h.

◆ NoDecorators()

FORCEINLINE auto Mcro::Range::NoDecorators ( )

Don't insert anything else than the contents of the input range when that is rendered as a string just append each item one after the other.

Definition at line 123 of file Conversion.h.

◆ NoEnclosure()

FORCEINLINE auto Mcro::Range::NoEnclosure ( )

Don't enclose this range in anything when it's rendered to a string.

Definition at line 104 of file Conversion.h.

◆ NoSeparator()

FORCEINLINE auto Mcro::Range::NoSeparator ( )

Don't use a separator when this range is rendered to a string.

Definition at line 90 of file Conversion.h.

◆ RenderAsString() [1/2]

FORCEINLINE auto Mcro::Range::RenderAsString ( )

Definition at line 245 of file Conversion.h.

◆ RenderAsString() [2/2]

template<CRangeMember Range>
FString Mcro::Range::RenderAsString ( Range && range)

Render an input range as a string.

For ranges of any char type, the output is an uninterrupted string of them. Other char types than TCHAR will be converted to the encoding of the current TCHAR.

For ranges of strings and string-views individual items will be directly copy-appended to the output separated by , (unless another separator sequence is set via Separator)

For anything else, Mcro::Text::AsString is used. In fact this function serves as the basis for AsString for any range type. Like for strings, any other type is separated by , (unless another separator sequence is set via Separator). For convenience a piped version is also provided of this function.

Definition at line 179 of file Conversion.h.

◆ SelectTupleItem() [1/2]

template<size_t ItemIndex>
auto Mcro::Range::SelectTupleItem ( )

Definition at line 338 of file Views.h.

◆ SelectTupleItem() [2/2]

template<size_t ItemIndex, CRangeOfTuples Range>
auto Mcro::Range::SelectTupleItem ( Range && left)

Definition at line 328 of file Views.h.

◆ Separator()

FORCEINLINE auto Mcro::Range::Separator ( FString const & separator)

Specify a separator sequence for a range when converting it to a string.

Definition at line 61 of file Conversion.h.

◆ TransformTuple() [1/2]

template<CFunctionLike Transform, CRangeOfTuplesCompatibleWithFunction< Transform > Left>
auto Mcro::Range::TransformTuple ( Left && left,
Transform && tr )

Transform a range of tuples with structured binding function arguments, so range transformations shouldn't bother with the actual type of the tuple.

For example:

int32 size = 4;
// | highFreq | lowFreq
namespace rv = ranges::views; // V V
auto things = rv::cartesian(rv::indices(0, size), rv::indices(0, size))
| TransformTuple([size](int32 highFreq, int32 lowFreq)
{
return lowFreq * size + highFreq;
})
;
FMT_LOG(LogTemp, Display, "Things: {0}", things);
//-> Things: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
auto TransformTuple(Left &&left, Transform &&tr)
Transform a range of tuples with structured binding function arguments, so range transformations shou...
Definition Views.h:216
Template Parameters
TransformA transformation function type with signature compatible with input tuple.
LeftThe type of the range of tuples
Parameters
leftThe range of tuples
trA transformation function with signature compatible with input tuple.
Returns
Range with transformed elements

Definition at line 216 of file Views.h.

◆ TransformTuple() [2/2]

template<CFunctionLike Transform>
auto Mcro::Range::TransformTuple ( Transform && tr)

Transform a range of tuples with structured binding function arguments, so range transformations shouldn't bother with the actual type of the tuple.

For example:

int32 size = 4;
// | highFreq | lowFreq
namespace rv = ranges::views; // V V
auto things = rv::cartesian(rv::indices(0, size), rv::indices(0, size))
| TransformTuple([size](int32 highFreq, int32 lowFreq)
{
return lowFreq * size + highFreq;
})
;
FMT_LOG(LogTemp, Display, "Things: {0}", things);
//-> Things: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
Template Parameters
TransformA transformation function type with signature compatible with input tuple.
Parameters
trA transformation function with signature compatible with input tuple.
Returns
Range with transformed elements

Definition at line 250 of file Views.h.

◆ Zip()

template<CRangeMember... Ranges>
auto Mcro::Range::Zip ( Ranges &&... right)

pipeable version of ranges::views::zip

Definition at line 31 of file Views.h.

Variable Documentation

◆ TIteratorCompare

template<typename T >
TIteratorCompare_Struct<T> Mcro::Range::TIteratorCompare
constexpr

Definition at line 177 of file Iterators.h.

◆ TIteratorComputeDistance

template<typename T >
TIteratorComputeDistance_Struct<T> Mcro::Range::TIteratorComputeDistance
constexpr

Definition at line 253 of file Iterators.h.

◆ TIteratorDirection

template<typename T >
EIteratorDirection Mcro::Range::TIteratorDirection
constexpr
Initial value:
=
? EIteratorDirection::Bidirectional
? EIteratorDirection::Forward
: EIteratorDirection::NotIterator

Get the direction given iterator is capable of.

Definition at line 97 of file Concepts.h.

◆ TIteratorJumpBackward

template<typename T >
TIteratorJumpBackward_Struct<T> Mcro::Range::TIteratorJumpBackward
constexpr

Definition at line 105 of file Iterators.h.

◆ TIteratorJumpForward

template<typename T >
TIteratorJumpForward_Struct<T> Mcro::Range::TIteratorJumpForward
constexpr

Definition at line 72 of file Iterators.h.

◆ TIteratorStep

template<typename T >
EIteratorStep Mcro::Range::TIteratorStep
constexpr
Initial value:
=
? EIteratorStep::JumpBinaryOperators
? EIteratorStep::Jump
? EIteratorStep::Single
: EIteratorStep::NotIterator
An iterator type which can natively proceed forward in arbitrarily large steps.
Definition Concepts.h:70
An iterator type which can natively proceed forward in arbitrarily large steps and exposes a + operat...
Definition Concepts.h:74

Get the maximum steps the given iterator can be seeking with.

Definition at line 107 of file Concepts.h.