MCRO
C++23 utilities for Unreal Engine.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
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
 

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 CConvertibleToDecayed<TRangeElementType<Right>, TRangeElementType<Left>>
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 CConvertibleToDecayed<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 ()
 

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:68
An iterator type which can natively seek its associated content in arbitrarily large steps.
Definition Concepts.h:80

Assume an STL iterator category from input iterator.

Definition at line 121 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 159 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 163 of file Concepts.h.

Enumeration Type Documentation

◆ EIteratorDirection

Enumerator
NotIterator 
Forward 
Bidirectional 

Definition at line 26 of file Concepts.h.

◆ EIteratorStep

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

Definition at line 32 of file Concepts.h.

Function Documentation

◆ AllOf()

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

Definition at line 168 of file Views.h.

◆ AnyOf()

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

Definition at line 174 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.

◆ FilterValid()

FORCEINLINE auto Mcro::Range::FilterValid ( )

Definition at line 179 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.

◆ 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 47 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 CConvertibleToDecayed<TRangeElementType<Right>, TRangeElementType<Left>>
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 114 of file Views.h.

◆ MatchOrdered() [2/4]

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

Definition at line 139 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 156 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 162 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.

◆ 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.

◆ 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 99 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:72
An iterator type which can natively proceed forward in arbitrarily large steps and exposes a + operat...
Definition Concepts.h:76

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

Definition at line 109 of file Concepts.h.