Compare commits
4 Commits
1e6beb83f2
...
a92422e8b2
Author | SHA1 | Date | |
---|---|---|---|
a92422e8b2 | |||
343007ffd6 | |||
8c228fbf52 | |||
a14fbd90db |
@ -1,4 +1,4 @@
|
||||
#include "Numeric/Random.h"
|
||||
#include "Numerics/Random.h"
|
||||
|
||||
#include "Templates/Atomic.h"
|
||||
|
||||
|
45
Redcraft.Utility/Source/Private/Testing/Algorithms.cpp
Normal file
45
Redcraft.Utility/Source/Private/Testing/Algorithms.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "Testing/Testing.h"
|
||||
|
||||
#include "Algorithms/Algorithms.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "Containers/List.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Testing)
|
||||
|
||||
NAMESPACE_PRIVATE_BEGIN
|
||||
|
||||
void TestBasic()
|
||||
{
|
||||
TArray<int> Arr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
auto Iter = Arr.Begin();
|
||||
|
||||
Algorithms::Advance(Iter, 5);
|
||||
|
||||
always_check(*Iter == 5);
|
||||
|
||||
always_check(Algorithms::Distance(Arr.Begin(), Iter) == 5);
|
||||
|
||||
always_check(Algorithms::Distance(Arr) == 10);
|
||||
|
||||
always_check(*Algorithms::Next(Iter, 2) == 7);
|
||||
always_check(*Algorithms::Prev(Iter, 2) == 3);
|
||||
}
|
||||
|
||||
NAMESPACE_PRIVATE_END
|
||||
|
||||
void TestAlgorithms()
|
||||
{
|
||||
NAMESPACE_PRIVATE::TestBasic();
|
||||
}
|
||||
|
||||
NAMESPACE_END(Testing)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
@ -1,6 +1,6 @@
|
||||
#include "Testing/Testing.h"
|
||||
|
||||
#include "Iterator/Iterator.h"
|
||||
#include "Iterators/Iterators.h"
|
||||
#include "Containers/List.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "Testing/Testing.h"
|
||||
|
||||
#include "Numeric/Numeric.h"
|
||||
#include "Numerics/Numerics.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
471
Redcraft.Utility/Source/Private/Testing/Ranges.cpp
Normal file
471
Redcraft.Utility/Source/Private/Testing/Ranges.cpp
Normal file
@ -0,0 +1,471 @@
|
||||
#include "Testing/Testing.h"
|
||||
|
||||
#include "Ranges/Ranges.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "Containers/List.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Testing)
|
||||
|
||||
NAMESPACE_PRIVATE_BEGIN
|
||||
|
||||
void TestConversion()
|
||||
{
|
||||
{
|
||||
const TArray<int> Arr = { 1, 2, 3, 4, 5 };
|
||||
const TList<int> List = { 1, 2, 3, 4, 5 };
|
||||
|
||||
const TArray<int> Brr = Ranges::View(List.Begin(), List.End()) | Ranges::To<TArray<int>>();
|
||||
const TList<int> Mist = Ranges::View(Arr.Begin(), Arr.End()) | Ranges::To<TList<int>>();
|
||||
|
||||
always_check(Arr == Brr);
|
||||
always_check(List == Mist);
|
||||
}
|
||||
|
||||
{
|
||||
const TArray<int> Arr = { 1, 2, 3, 4, 5 };
|
||||
const TList<int> List = { 1, 2, 3, 4, 5 };
|
||||
|
||||
const TArray<int> Brr = Ranges::View(List.Begin(), List.End()) | Ranges::To<TArray>();
|
||||
const TList<int> Mist = Ranges::View(Arr.Begin(), Arr.End()) | Ranges::To<TList>();
|
||||
|
||||
always_check(Arr == Brr);
|
||||
always_check(List == Mist);
|
||||
}
|
||||
}
|
||||
|
||||
void TestFactory()
|
||||
{
|
||||
{
|
||||
const TArray<int> Arr = { };
|
||||
const TArray<int> Brr = Ranges::Empty<int> | Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Arr == Brr);
|
||||
}
|
||||
|
||||
{
|
||||
const TArray<int> Arr = { 1 };
|
||||
const TArray<int> Brr = Ranges::Single(1) | Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Arr == Brr);
|
||||
}
|
||||
|
||||
{
|
||||
const TArray<int> Arr = { 0, 1, 2, 3, 4 };
|
||||
const TArray<int> Brr = Ranges::Iota(0, 5) | Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Arr == Brr);
|
||||
}
|
||||
|
||||
{
|
||||
auto View = Ranges::Iota(0, 5);
|
||||
|
||||
always_check(View.Num() == 5);
|
||||
always_check(!View.IsEmpty());
|
||||
always_check(!!View);
|
||||
|
||||
always_check(View.Front() == 0);
|
||||
|
||||
auto First = View.Begin();
|
||||
auto Last = View.End();
|
||||
|
||||
auto ConstFirst = AsConst(View).Begin();
|
||||
auto ConstLast = AsConst(View).End();
|
||||
|
||||
always_check(First == ConstFirst);
|
||||
always_check(Last == ConstLast );
|
||||
|
||||
ConstFirst = First;
|
||||
ConstLast = Last;
|
||||
|
||||
auto Iter = ConstFirst;
|
||||
auto Jter = ConstLast;
|
||||
|
||||
++Iter;
|
||||
|
||||
always_check(*Iter++ == 1);
|
||||
}
|
||||
|
||||
{
|
||||
auto View = Ranges::Iota(0);
|
||||
|
||||
always_check(!View.IsEmpty());
|
||||
always_check(!!View);
|
||||
|
||||
always_check(View.Front() == 0);
|
||||
|
||||
auto First = View.Begin();
|
||||
auto Last = View.End();
|
||||
|
||||
auto ConstFirst = AsConst(View).Begin();
|
||||
auto ConstLast = AsConst(View).End();
|
||||
|
||||
always_check(First == ConstFirst);
|
||||
|
||||
ConstFirst = First;
|
||||
ConstLast = Last;
|
||||
|
||||
auto Iter = ConstFirst;
|
||||
auto Jter = ConstLast;
|
||||
|
||||
++Iter;
|
||||
|
||||
always_check(*Iter++ == 1);
|
||||
}
|
||||
|
||||
{
|
||||
const TArray<int> Arr = { 0, 0, 0, 0, 0 };
|
||||
const TArray<int> Brr = Ranges::Repeat(0, 5) | Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Arr == Brr);
|
||||
}
|
||||
|
||||
{
|
||||
auto View = Ranges::Repeat(0, 8);
|
||||
|
||||
always_check(View.Num() == 8);
|
||||
always_check(!View.IsEmpty());
|
||||
always_check(!!View);
|
||||
|
||||
always_check(View.Front() == 0);
|
||||
always_check(View.Back() == 0);
|
||||
|
||||
auto First = View.Begin();
|
||||
auto Last = View.End();
|
||||
|
||||
auto ConstFirst = AsConst(View).Begin();
|
||||
auto ConstLast = AsConst(View).End();
|
||||
|
||||
always_check(First == ConstFirst);
|
||||
always_check(Last == ConstLast );
|
||||
|
||||
always_check(ConstLast - First == 8);
|
||||
|
||||
ConstFirst = First;
|
||||
ConstLast = Last;
|
||||
|
||||
auto Iter = ConstFirst;
|
||||
auto Jter = ConstLast;
|
||||
|
||||
++Iter;
|
||||
--Jter;
|
||||
|
||||
always_check(*Iter++ == 0);
|
||||
always_check(*Jter-- == 0);
|
||||
|
||||
Iter += 2;
|
||||
Jter -= 2;
|
||||
|
||||
always_check(Iter[-1] == 0);
|
||||
always_check(Jter[ 1] == 0);
|
||||
|
||||
Iter = Iter - 2;
|
||||
Jter = Jter + 2;
|
||||
|
||||
always_check(*Iter == 0);
|
||||
always_check(*Jter == 0);
|
||||
|
||||
Iter = 2 + Iter;
|
||||
Jter = Jter - 2;
|
||||
|
||||
always_check(Iter - Jter == 0);
|
||||
}
|
||||
|
||||
{
|
||||
auto View = Ranges::Repeat(0);
|
||||
|
||||
always_check(!View.IsEmpty());
|
||||
always_check(!!View);
|
||||
|
||||
always_check(View.Front() == 0);
|
||||
|
||||
auto First = View.Begin();
|
||||
auto Last = View.End();
|
||||
|
||||
auto ConstFirst = AsConst(View).Begin();
|
||||
auto ConstLast = AsConst(View).End();
|
||||
|
||||
always_check(First == ConstFirst);
|
||||
|
||||
ConstFirst = First;
|
||||
ConstLast = Last;
|
||||
|
||||
auto Iter = ConstFirst;
|
||||
auto Jter = ConstFirst + 8;
|
||||
|
||||
++Iter;
|
||||
--Jter;
|
||||
|
||||
always_check(*Iter++ == 0);
|
||||
always_check(*Jter-- == 0);
|
||||
|
||||
Iter += 2;
|
||||
Jter -= 2;
|
||||
|
||||
always_check(Iter[-1] == 0);
|
||||
always_check(Jter[ 1] == 0);
|
||||
|
||||
Iter = Iter - 2;
|
||||
Jter = Jter + 2;
|
||||
|
||||
always_check(*Iter == 0);
|
||||
always_check(*Jter == 0);
|
||||
|
||||
Iter = 2 + Iter;
|
||||
Jter = Jter - 2;
|
||||
|
||||
always_check(Iter - Jter == 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TestAllView()
|
||||
{
|
||||
TArray<int> Arr = { 0, 1, 2, 3, 4 };
|
||||
|
||||
TArray<int> Brr = Ranges::All(Arr) | Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Arr == Brr);
|
||||
|
||||
auto View = Ranges::All(MoveTemp(Arr));
|
||||
|
||||
Arr.Reset();
|
||||
|
||||
TArray<int> Crr = View | Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Brr == Crr);
|
||||
}
|
||||
|
||||
void TestMoveView()
|
||||
{
|
||||
{
|
||||
struct FTracker
|
||||
{
|
||||
FTracker() = default;
|
||||
FTracker(const FTracker&) { always_check_no_entry(); }
|
||||
FTracker(FTracker&&) = default;
|
||||
~FTracker() = default;
|
||||
FTracker& operator=(const FTracker&) { always_check_no_entry(); }
|
||||
FTracker& operator=(FTracker&&) = default;
|
||||
};
|
||||
|
||||
FTracker Arr[2];
|
||||
|
||||
auto View = Arr | Ranges::Move();
|
||||
|
||||
auto First = View.Begin();
|
||||
auto Last = View.End();
|
||||
|
||||
FTracker Temp(*First++);
|
||||
|
||||
Temp = *First++;
|
||||
|
||||
always_check(First == Last);
|
||||
}
|
||||
|
||||
{
|
||||
TArray<int> Arr = { 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||
|
||||
auto View = Arr | Ranges::Move();
|
||||
|
||||
always_check(View.Num() == 8);
|
||||
always_check(!View.IsEmpty());
|
||||
always_check(!!View);
|
||||
|
||||
always_check(View.Front() == 0);
|
||||
always_check(View.Back() == 7);
|
||||
|
||||
auto First = View.Begin();
|
||||
auto Last = View.End();
|
||||
|
||||
auto ConstFirst = AsConst(View).Begin();
|
||||
auto ConstLast = AsConst(View).End();
|
||||
|
||||
always_check(First == ConstFirst);
|
||||
always_check(Last == ConstLast );
|
||||
|
||||
always_check(ConstLast - First == 8);
|
||||
|
||||
ConstFirst = First;
|
||||
ConstLast = Last;
|
||||
|
||||
auto Iter = ConstFirst;
|
||||
auto Jter = ConstLast;
|
||||
|
||||
++Iter;
|
||||
--Jter;
|
||||
|
||||
always_check(*Iter++ == 1);
|
||||
always_check(*Jter-- == 7);
|
||||
|
||||
Iter += 2;
|
||||
Jter -= 2;
|
||||
|
||||
always_check(Iter[-1] == 3);
|
||||
always_check(Jter[ 1] == 5);
|
||||
|
||||
Iter = Iter - 2;
|
||||
Jter = Jter + 2;
|
||||
|
||||
always_check(*Iter == 2);
|
||||
always_check(*Jter == 6);
|
||||
|
||||
Iter = 2 + Iter;
|
||||
Jter = Jter - 2;
|
||||
|
||||
always_check(Iter - Jter == 0);
|
||||
}
|
||||
|
||||
{
|
||||
auto View = Ranges::Iota(0) | Ranges::Move();
|
||||
|
||||
always_check(!View.IsEmpty());
|
||||
always_check(!!View);
|
||||
|
||||
always_check(View.Front() == 0);
|
||||
|
||||
auto First = View.Begin();
|
||||
auto Last = View.End();
|
||||
|
||||
auto ConstFirst = AsConst(View).Begin();
|
||||
auto ConstLast = AsConst(View).End();
|
||||
|
||||
always_check(First == ConstFirst);
|
||||
|
||||
ConstFirst = First;
|
||||
ConstLast = Last;
|
||||
|
||||
auto Iter = ConstFirst;
|
||||
auto Jter = ConstLast;
|
||||
|
||||
++Iter;
|
||||
|
||||
always_check(*Iter++ == 1);
|
||||
}
|
||||
}
|
||||
|
||||
void TestMiscView()
|
||||
{
|
||||
{
|
||||
TArray<int> Arr = { 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||
TArray<int> Brr = { 0, 2, 4, 6 };
|
||||
|
||||
TArray<int> Crr = Arr
|
||||
| Ranges::Filter([](int Value) { return Value % 2 == 0; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Brr == Crr);
|
||||
}
|
||||
|
||||
{
|
||||
TArray<int> Arr = { 0, 1, 2, 2, 1, 0 };
|
||||
TArray<int> Brr = { 0, 2, 4, 4, 2, 0 };
|
||||
|
||||
TArray<int> Crr = Arr
|
||||
| Ranges::Transform([](int Value) { return Value * 2; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Brr == Crr);
|
||||
}
|
||||
|
||||
{
|
||||
TArray<int> Arr = { 0, 1, 2, 3, 3, 2, 1, 0 };
|
||||
TArray<int> Brr = { 0, 2, 4, 4, 2, 0 };
|
||||
|
||||
TArray<int> Crr = Arr
|
||||
| Ranges::Filter ([](int Value) { return Value < 3; })
|
||||
| Ranges::Transform([](int Value) { return Value * 2; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
TArray<int> Drr = Arr
|
||||
| Ranges::Transform([](int Value) { return Value * 2; })
|
||||
| Ranges::Filter ([](int Value) { return Value < 6; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Brr == Crr);
|
||||
always_check(Brr == Drr);
|
||||
}
|
||||
|
||||
{
|
||||
TArray<int> Arr = { 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||
|
||||
TArray<int> Brr = Ranges::Iota(0)
|
||||
| Ranges::Take(8)
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
TArray<int> Crr = Ranges::Iota(0)
|
||||
| Ranges::TakeWhile([](int Value) { return Value < 8; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Arr == Brr);
|
||||
always_check(Arr == Crr);
|
||||
}
|
||||
|
||||
{
|
||||
TArray<int> Arr = { 0, 4, 7, 8, 3, 1, 10 };
|
||||
TArray<int> Brr = { 0, 2, 4 };
|
||||
|
||||
TArray<int> Crr = Arr
|
||||
| Ranges::Filter ([](int Value) { return Value % 2 == 0; })
|
||||
| Ranges::Take(3)
|
||||
| Ranges::Transform([](int Value) { return Value / 2; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
TArray<int> Drr = Arr
|
||||
| Ranges::Filter ([](int Value) { return Value % 2 == 0; })
|
||||
| Ranges::TakeWhile([](int Value) { return Value < 10; })
|
||||
| Ranges::Transform([](int Value) { return Value / 2; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
TArray<int> Err = Arr
|
||||
| Ranges::Filter ([](int Value) { return Value % 2 == 0; })
|
||||
| Ranges::Transform([](int Value) { return Value / 2; })
|
||||
| Ranges::Take(3)
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
TArray<int> Frr = Arr
|
||||
| Ranges::Filter ([](int Value) { return Value % 2 == 0; })
|
||||
| Ranges::Transform([](int Value) { return Value / 2; })
|
||||
| Ranges::TakeWhile([](int Value) { return Value < 5; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
TArray<int> Grr = Arr
|
||||
| Ranges::Take(6)
|
||||
| Ranges::Filter ([](int Value) { return Value % 2 == 0; })
|
||||
| Ranges::Transform([](int Value) { return Value / 2; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
TArray<int> Hrr = Arr
|
||||
| Ranges::TakeWhile([](int Value) { return Value < 10; })
|
||||
| Ranges::Filter ([](int Value) { return Value % 2 == 0; })
|
||||
| Ranges::Transform([](int Value) { return Value / 2; })
|
||||
| Ranges::To<TArray<int>>();
|
||||
|
||||
always_check(Brr == Crr);
|
||||
always_check(Brr == Drr);
|
||||
always_check(Brr == Err);
|
||||
always_check(Brr == Frr);
|
||||
always_check(Brr == Grr);
|
||||
always_check(Brr == Hrr);
|
||||
}
|
||||
}
|
||||
|
||||
NAMESPACE_PRIVATE_END
|
||||
|
||||
void TestRange()
|
||||
{
|
||||
NAMESPACE_PRIVATE::TestConversion();
|
||||
NAMESPACE_PRIVATE::TestFactory();
|
||||
NAMESPACE_PRIVATE::TestAllView();
|
||||
NAMESPACE_PRIVATE::TestMoveView();
|
||||
NAMESPACE_PRIVATE::TestMiscView();
|
||||
}
|
||||
|
||||
NAMESPACE_END(Testing)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
@ -1,10 +1,10 @@
|
||||
#include "Testing/Testing.h"
|
||||
|
||||
#include "String/Char.h"
|
||||
#include "Strings/Char.h"
|
||||
#include "Memory/Memory.h"
|
||||
#include "String/String.h"
|
||||
#include "Numeric/Numeric.h"
|
||||
#include "String/StringView.h"
|
||||
#include "Strings/String.h"
|
||||
#include "Numerics/Numerics.h"
|
||||
#include "Strings/StringView.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
4
Redcraft.Utility/Source/Public/Algorithms/Algorithms.h
Normal file
4
Redcraft.Utility/Source/Public/Algorithms/Algorithms.h
Normal file
@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Algorithms/Basic.h"
|
86
Redcraft.Utility/Source/Public/Algorithms/Basic.h
Normal file
86
Redcraft.Utility/Source/Public/Algorithms/Basic.h
Normal file
@ -0,0 +1,86 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Algorithms)
|
||||
|
||||
/** Increments given iterator 'Iter' by 'N' elements. */
|
||||
template <CInputIterator I>
|
||||
FORCEINLINE constexpr void Advance(I& Iter, ptrdiff N)
|
||||
{
|
||||
if constexpr (CRandomAccessIterator<I>)
|
||||
{
|
||||
Iter += N;
|
||||
}
|
||||
|
||||
else if constexpr (CBidirectionalIterator<I>)
|
||||
{
|
||||
for (; N > 0; --N) ++Iter;
|
||||
for (; N < 0; ++N) --Iter;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
checkf(N >= 0, TEXT("The iterator must satisfy the CBidirectionalIterator in order to be decremented."));
|
||||
for (; N > 0; --N) ++Iter;
|
||||
}
|
||||
}
|
||||
|
||||
/** @return The number of hops from 'First' to 'Last'. */
|
||||
template <CInputIterator I, CSentinelFor<I> S>
|
||||
NODISCARD FORCEINLINE constexpr ptrdiff Distance(I First, S Last)
|
||||
{
|
||||
if constexpr (CSizedSentinelFor<S, I>)
|
||||
{
|
||||
return Last - First;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptrdiff Result = 0;
|
||||
for (; First != Last; ++First) ++Result;
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
|
||||
/** @return The size of the range. */
|
||||
template <CRange R>
|
||||
NODISCARD FORCEINLINE constexpr ptrdiff Distance(R&& Range)
|
||||
{
|
||||
if constexpr (CSizedRange<R>)
|
||||
{
|
||||
return static_cast<ptrdiff>(Ranges::Num(Range));
|
||||
}
|
||||
else return Algorithms::Distance(Ranges::Begin(Range), Ranges::End(Range));
|
||||
}
|
||||
|
||||
/** @return The 'N'-th successor of iterator 'Iter'. */
|
||||
template <CInputIterator I>
|
||||
NODISCARD FORCEINLINE constexpr I Next(I Iter, ptrdiff N = 1)
|
||||
{
|
||||
Algorithms::Advance(Iter, N);
|
||||
return Iter;
|
||||
}
|
||||
|
||||
/** @return The 'N'-th predecessor of iterator 'Iter'. */
|
||||
template <CBidirectionalIterator I>
|
||||
NODISCARD FORCEINLINE constexpr I Prev(I Iter, ptrdiff N = 1)
|
||||
{
|
||||
Algorithms::Advance(Iter, -N);
|
||||
return Iter;
|
||||
}
|
||||
|
||||
NAMESPACE_END(Algorithms)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
@ -4,14 +4,14 @@
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Memory/Allocators.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Factory.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/ReverseIterator.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/Factory.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
@ -60,7 +60,7 @@ public:
|
||||
|
||||
/** Constructs the container with 'Count' copies of elements with 'InValue'. */
|
||||
FORCEINLINE explicit TArray(size_t Count, const FElementType& InValue) requires (CCopyConstructible<T>)
|
||||
: TArray(Range::Repeat(InValue, Count))
|
||||
: TArray(Ranges::Repeat(InValue, Count))
|
||||
{ }
|
||||
|
||||
/** Constructs the container with the contents of the range ['First', 'Last'). */
|
||||
@ -104,7 +104,7 @@ public:
|
||||
|
||||
/** Constructs the container with the contents of the range. */
|
||||
template <CInputRange R> requires (!CSameAs<TRemoveCVRef<R>, TArray> && CConstructibleFrom<T, TRangeReference<R>> && CMovable<T>)
|
||||
FORCEINLINE explicit TArray(R&& Range) : TArray(Range::Begin(Range), Range::End(Range)) { }
|
||||
FORCEINLINE explicit TArray(R&& Range) : TArray(Ranges::Begin(Range), Ranges::End(Range)) { }
|
||||
|
||||
/** Copy constructor. Constructs the container with the copy of the contents of 'InValue'. */
|
||||
TArray(const TArray& InValue) requires (CCopyConstructible<T>)
|
||||
@ -142,7 +142,7 @@ public:
|
||||
}
|
||||
|
||||
/** Constructs the container with the contents of the initializer list. */
|
||||
FORCEINLINE TArray(initializer_list<FElementType> IL) requires (CCopyConstructible<T>) : TArray(Range::Begin(IL), Range::End(IL)) { }
|
||||
FORCEINLINE TArray(initializer_list<FElementType> IL) requires (CCopyConstructible<T>) : TArray(Ranges::Begin(IL), Ranges::End(IL)) { }
|
||||
|
||||
/** Destructs the array. The destructors of the elements are called and the used storage is deallocated. */
|
||||
~TArray()
|
||||
@ -256,38 +256,38 @@ public:
|
||||
/** Replaces the contents with those identified by initializer list. */
|
||||
TArray& operator=(initializer_list<FElementType> IL) requires (CCopyable<T>)
|
||||
{
|
||||
size_t NumToAllocate = Range::Num(IL);
|
||||
size_t NumToAllocate = Ranges::Num(IL);
|
||||
|
||||
NumToAllocate = NumToAllocate > Max() ? Impl->CalculateSlackGrow (Range::Num(IL), Max()) : NumToAllocate;
|
||||
NumToAllocate = NumToAllocate < Max() ? Impl->CalculateSlackShrink(Range::Num(IL), Max()) : NumToAllocate;
|
||||
NumToAllocate = NumToAllocate > Max() ? Impl->CalculateSlackGrow (Ranges::Num(IL), Max()) : NumToAllocate;
|
||||
NumToAllocate = NumToAllocate < Max() ? Impl->CalculateSlackShrink(Ranges::Num(IL), Max()) : NumToAllocate;
|
||||
|
||||
if (NumToAllocate != Max())
|
||||
{
|
||||
Memory::Destruct(Impl.Pointer, Num());
|
||||
Impl->Deallocate(Impl.Pointer);
|
||||
|
||||
Impl.ArrayNum = Range::Num(IL);
|
||||
Impl.ArrayNum = Ranges::Num(IL);
|
||||
Impl.ArrayMax = NumToAllocate;
|
||||
Impl.Pointer = Impl->Allocate(Max());
|
||||
|
||||
Memory::CopyConstruct<FElementType>(Impl.Pointer, Range::GetData(IL), Num());
|
||||
Memory::CopyConstruct<FElementType>(Impl.Pointer, Ranges::GetData(IL), Num());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (Range::Num(IL) <= Num())
|
||||
if (Ranges::Num(IL) <= Num())
|
||||
{
|
||||
Memory::CopyAssign(Impl.Pointer, Range::GetData(IL), Range::Num(IL));
|
||||
Memory::Destruct(Impl.Pointer + Range::Num(IL), Num() - Range::Num(IL));
|
||||
Memory::CopyAssign(Impl.Pointer, Ranges::GetData(IL), Ranges::Num(IL));
|
||||
Memory::Destruct(Impl.Pointer + Ranges::Num(IL), Num() - Ranges::Num(IL));
|
||||
}
|
||||
else if (Range::Num(IL) <= Max())
|
||||
else if (Ranges::Num(IL) <= Max())
|
||||
{
|
||||
Memory::CopyAssign(Impl.Pointer, Range::GetData(IL), Num());
|
||||
Memory::CopyConstruct<FElementType>(Impl.Pointer + Num(), Range::GetData(IL) + Num(), Range::Num(IL) - Num());
|
||||
Memory::CopyAssign(Impl.Pointer, Ranges::GetData(IL), Num());
|
||||
Memory::CopyConstruct<FElementType>(Impl.Pointer + Num(), Ranges::GetData(IL) + Num(), Ranges::Num(IL) - Num());
|
||||
}
|
||||
else check_no_entry();
|
||||
|
||||
Impl.ArrayNum = Range::Num(IL);
|
||||
Impl.ArrayNum = Ranges::Num(IL);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -419,7 +419,7 @@ public:
|
||||
{
|
||||
checkf(IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Insert(Iter, Range::Repeat(InValue, Count));
|
||||
return Insert(Iter, Ranges::Repeat(InValue, Count));
|
||||
}
|
||||
|
||||
/** Inserts elements from range ['First', 'Last') before 'Iter'. */
|
||||
@ -546,13 +546,13 @@ public:
|
||||
template <CInputRange R> requires (CConstructibleFrom<T, TRangeReference<R>> && CAssignableFrom<T&, TRangeReference<R>> && CMovable<T>)
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, R&& Range)
|
||||
{
|
||||
return Insert(Iter, Range::Begin(Range), Range::End(Range));
|
||||
return Insert(Iter, Ranges::Begin(Range), Ranges::End(Range));
|
||||
}
|
||||
|
||||
/** Inserts elements from initializer list before 'Iter' in the container. */
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list<FElementType> IL) requires (CCopyable<T>)
|
||||
{
|
||||
return Insert(Iter, Range::Begin(IL), Range::End(IL));
|
||||
return Insert(Iter, Ranges::Begin(IL), Ranges::End(IL));
|
||||
}
|
||||
|
||||
/** Inserts a new element into the container directly before 'Iter'. */
|
||||
|
@ -4,10 +4,10 @@
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/ReverseIterator.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "Containers/StaticArray.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
|
@ -5,12 +5,12 @@
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Templates/Noncopyable.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Memory/Allocators.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/ReverseIterator.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
@ -135,7 +135,7 @@ public:
|
||||
|
||||
/** Constructs the bitset with the bits of the range. */
|
||||
template <CInputRange R> requires (!CSameAs<TRemoveCVRef<R>, TBitset> && CConstructibleFrom<bool, TRangeReference<R>>)
|
||||
FORCEINLINE explicit TBitset(R&& Range) : TBitset(Range::Begin(Range), Range::End(Range)) { }
|
||||
FORCEINLINE explicit TBitset(R&& Range) : TBitset(Ranges::Begin(Range), Ranges::End(Range)) { }
|
||||
|
||||
/** Copy constructor. Constructs the bitset with the copy of the bits of 'InValue'. */
|
||||
FORCEINLINE TBitset(const TBitset& InValue)
|
||||
@ -171,7 +171,7 @@ public:
|
||||
}
|
||||
|
||||
/** Constructs the bitset with the bits of the initializer list. */
|
||||
FORCEINLINE TBitset(initializer_list<bool> IL) : TBitset(Range::Begin(IL), Range::End(IL)) { }
|
||||
FORCEINLINE TBitset(initializer_list<bool> IL) : TBitset(Ranges::Begin(IL), Ranges::End(IL)) { }
|
||||
|
||||
/** Destructs the bitset. The storage is deallocated. */
|
||||
~TBitset()
|
||||
@ -239,9 +239,9 @@ public:
|
||||
/** Replaces the bits with those identified by initializer list. */
|
||||
TBitset& operator=(initializer_list<bool> IL)
|
||||
{
|
||||
auto First = Range::Begin(IL);
|
||||
auto First = Ranges::Begin(IL);
|
||||
|
||||
const size_t BlocksCount = (Range::Num(IL) + BlockWidth - 1) / BlockWidth;
|
||||
const size_t BlocksCount = (Ranges::Num(IL) + BlockWidth - 1) / BlockWidth;
|
||||
|
||||
size_t NumToAllocate = BlocksCount;
|
||||
|
||||
@ -252,7 +252,7 @@ public:
|
||||
{
|
||||
Impl->Deallocate(Impl.Pointer);
|
||||
|
||||
Impl.BitsetNum = Range::Num(IL);
|
||||
Impl.BitsetNum = Ranges::Num(IL);
|
||||
Impl.BlocksMax = NumToAllocate;
|
||||
Impl.Pointer = Impl->Allocate(MaxBlocks());
|
||||
|
||||
@ -261,7 +261,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Impl.BitsetNum = Range::Num(IL);
|
||||
Impl.BitsetNum = Ranges::Num(IL);
|
||||
|
||||
for (FReference Ref : *this) Ref = *First++;
|
||||
|
||||
|
@ -4,14 +4,14 @@
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Memory/Allocators.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Factory.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/ReverseIterator.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/Factory.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
@ -79,7 +79,7 @@ public:
|
||||
|
||||
/** Constructs the container with 'Count' copies of elements with 'InValue'. */
|
||||
TList(size_t Count, const FElementType& InValue) requires (CCopyable<FElementType>)
|
||||
: TList(Range::Repeat(InValue, Count))
|
||||
: TList(Ranges::Repeat(InValue, Count))
|
||||
{ }
|
||||
|
||||
/** Constructs the container with the contents of the range ['First', 'Last'). */
|
||||
@ -106,7 +106,7 @@ public:
|
||||
|
||||
/** Constructs the container with the contents of the range. */
|
||||
template <CInputRange R> requires (!CSameAs<TRemoveCVRef<R>, TList> && CConstructibleFrom<FElementType, TRangeReference<R>>)
|
||||
FORCEINLINE explicit TList(R&& Range) : TList(Range::Begin(Range), Range::End(Range)) { }
|
||||
FORCEINLINE explicit TList(R&& Range) : TList(Ranges::Begin(Range), Ranges::End(Range)) { }
|
||||
|
||||
/** Copy constructor. Constructs the container with the copy of the contents of 'InValue'. */
|
||||
FORCEINLINE TList(const TList& InValue) requires (CCopyConstructible<FElementType>) : TList(InValue.Begin(), InValue.End()) { }
|
||||
@ -115,7 +115,7 @@ public:
|
||||
FORCEINLINE TList(TList&& InValue) : TList() { Swap(*this, InValue); }
|
||||
|
||||
/** Constructs the container with the contents of the initializer list. */
|
||||
FORCEINLINE TList(initializer_list<FElementType> IL) requires (CCopyConstructible<FElementType>) : TList(Range::Begin(IL), Range::End(IL)) { }
|
||||
FORCEINLINE TList(initializer_list<FElementType> IL) requires (CCopyConstructible<FElementType>) : TList(Ranges::Begin(IL), Ranges::End(IL)) { }
|
||||
|
||||
/** Destructs the list. The destructors of the elements are called and the used storage is deallocated. */
|
||||
~TList()
|
||||
@ -176,9 +176,9 @@ public:
|
||||
TList& operator=(initializer_list<FElementType> IL) requires (CCopyable<FElementType>)
|
||||
{
|
||||
FIterator ThisIter = Begin();
|
||||
const FElementType* OtherIter = Range::Begin(IL);
|
||||
const FElementType* OtherIter = Ranges::Begin(IL);
|
||||
|
||||
while (ThisIter != End() && OtherIter != Range::End(IL))
|
||||
while (ThisIter != End() && OtherIter != Ranges::End(IL))
|
||||
{
|
||||
*ThisIter = *OtherIter;
|
||||
|
||||
@ -188,18 +188,18 @@ public:
|
||||
|
||||
if (ThisIter == End())
|
||||
{
|
||||
while (OtherIter != Range::End(IL))
|
||||
while (OtherIter != Ranges::End(IL))
|
||||
{
|
||||
EmplaceBack(*OtherIter);
|
||||
++OtherIter;
|
||||
}
|
||||
}
|
||||
else if (OtherIter == Range::End(IL))
|
||||
else if (OtherIter == Ranges::End(IL))
|
||||
{
|
||||
Erase(ThisIter, End());
|
||||
}
|
||||
|
||||
Impl.ListNum = Range::Num(IL);
|
||||
Impl.ListNum = Ranges::Num(IL);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -251,7 +251,7 @@ public:
|
||||
/** Inserts 'Count' copies of the 'InValue' before 'Iter' in the container. */
|
||||
FIterator Insert(FConstIterator Iter, size_t Count, const FElementType& InValue) requires (CCopyConstructible<FElementType>)
|
||||
{
|
||||
return Insert(Iter, Range::Repeat(InValue, Count));
|
||||
return Insert(Iter, Ranges::Repeat(InValue, Count));
|
||||
}
|
||||
|
||||
/** Inserts elements from range ['First', 'Last') before 'Iter'. */
|
||||
@ -291,10 +291,10 @@ public:
|
||||
|
||||
/** Inserts elements from range ['First', 'Last') before 'Iter'. */
|
||||
template <CInputRange R> requires (CConstructibleFrom<FElementType, TRangeReference<R>>)
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, R&& Range) { return Insert(Iter, Range::Begin(Range), Range::End(Range)); }
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, R&& Range) { return Insert(Iter, Ranges::Begin(Range), Ranges::End(Range)); }
|
||||
|
||||
/** Inserts elements from initializer list before 'Iter' in the container. */
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list<FElementType> IL) requires (CCopyConstructible<FElementType>) { return Insert(Iter, Range::Begin(IL), Range::End(IL)); }
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list<FElementType> IL) requires (CCopyConstructible<FElementType>) { return Insert(Iter, Ranges::Begin(IL), Ranges::End(IL)); }
|
||||
|
||||
/** Inserts a new element into the container directly before 'Iter'. */
|
||||
template <typename... Ts> requires (CConstructibleFrom<FElementType, Ts...>)
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/Meta.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/ReverseIterator.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Templates/Noncopyable.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/ReverseIterator.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Iterator/MoveIterator.h"
|
||||
#include "Iterator/CountedIterator.h"
|
||||
#include "Iterator/InsertIterator.h"
|
@ -2,8 +2,8 @@
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Memory/Address.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/Noncopyable.h"
|
||||
#include "Templates/Invoke.h"
|
10
Redcraft.Utility/Source/Public/Iterators/Iterators.h
Normal file
10
Redcraft.Utility/Source/Public/Iterators/Iterators.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/ReverseIterator.h"
|
||||
#include "Iterators/MoveIterator.h"
|
||||
#include "Iterators/CountedIterator.h"
|
||||
#include "Iterators/InsertIterator.h"
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Numeric/Literal.h"
|
||||
#include "Numeric/Limits.h"
|
||||
#include "Numeric/Numbers.h"
|
||||
#include "Numeric/Bit.h"
|
||||
#include "Numeric/Math.h"
|
||||
#include "Numeric/Random.h"
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Numeric/Limits.h"
|
||||
#include "Numeric/Literal.h"
|
||||
#include "Numerics/Limits.h"
|
||||
#include "Numerics/Literals.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
#include <bit>
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Numeric/Bit.h"
|
||||
#include "Numeric/Limits.h"
|
||||
#include "Numeric/Numbers.h"
|
||||
#include "Numerics/Bit.h"
|
||||
#include "Numerics/Limits.h"
|
||||
#include "Numerics/Numbers.h"
|
||||
#include "Templates/Tuple.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
9
Redcraft.Utility/Source/Public/Numerics/Numerics.h
Normal file
9
Redcraft.Utility/Source/Public/Numerics/Numerics.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Numerics/Literals.h"
|
||||
#include "Numerics/Limits.h"
|
||||
#include "Numerics/Numbers.h"
|
||||
#include "Numerics/Bit.h"
|
||||
#include "Numerics/Math.h"
|
||||
#include "Numerics/Random.h"
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Numeric/Bit.h"
|
||||
#include "Numeric/Math.h"
|
||||
#include "Numerics/Bit.h"
|
||||
#include "Numerics/Math.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/Conversion.h"
|
||||
#include "Range/Factory.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/AllView.h"
|
||||
#include "Range/MoveView.h"
|
||||
#include "Range/FilterView.h"
|
||||
#include "Range/TransformView.h"
|
||||
#include "Range/TakeView.h"
|
||||
#include "Range/TakeWhileView.h"
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Ranges/View.h"
|
||||
#include "Ranges/Pipe.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
@ -11,7 +11,7 @@ NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/**
|
||||
* A view adapter that references other range.
|
||||
@ -31,12 +31,12 @@ public:
|
||||
template <typename T> requires (!CSameAs<TRemoveCVRef<T>, TRefView> && CConvertibleTo<T, R&> && requires { Func(DeclVal<T>()); })
|
||||
FORCEINLINE constexpr TRefView(T&& InRange) : Ptr(AddressOf(static_cast<R&>(Forward<T>(InRange)))) { }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr TRangeIterator<R> Begin() const { return Range::Begin(*Ptr); }
|
||||
NODISCARD FORCEINLINE constexpr TRangeSentinel<R> End() const { return Range::End (*Ptr); }
|
||||
NODISCARD FORCEINLINE constexpr TRangeIterator<R> Begin() const { return Ranges::Begin(*Ptr); }
|
||||
NODISCARD FORCEINLINE constexpr TRangeSentinel<R> End() const { return Ranges::End (*Ptr); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousRange<R>) { return Range::GetData(*Ptr); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<R>) { return Range::Num (*Ptr); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (requires(R Range) { Range::IsEmpty(Range); }) { return Range::IsEmpty(*Ptr); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousRange<R>) { return Ranges::GetData(*Ptr); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<R>) { return Ranges::Num (*Ptr); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (requires(R Range) { Ranges::IsEmpty(Range); }) { return Ranges::IsEmpty(*Ptr); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr R& GetBase() const { return *Ptr; }
|
||||
|
||||
@ -61,12 +61,12 @@ static_assert( CView<TRefView< IRange<IInputOrOutputIterator<int>>>>)
|
||||
|
||||
static_assert(COutputRange<TRefView<IRange<IOutputIterator<int&>>>, int>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename T>
|
||||
constexpr bool bEnableBorrowedRange<Range::TRefView<T>> = true;
|
||||
constexpr bool bEnableBorrowedRange<Ranges::TRefView<T>> = true;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/**
|
||||
* A view adapter that has unique ownership of a range.
|
||||
@ -88,19 +88,19 @@ public:
|
||||
FORCEINLINE constexpr TOwningView& operator=(const TOwningView&) = delete;
|
||||
FORCEINLINE constexpr TOwningView& operator=(TOwningView&&) = default;
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() { return Range::Begin(Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto End() { return Range::End (Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const R>) { return Range::Begin(Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const R>) { return Range::End (Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() { return Ranges::Begin(Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto End() { return Ranges::End (Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const R>) { return Ranges::Begin(Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const R>) { return Ranges::End (Base); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() requires (CContiguousRange< R>) { return Range::GetData(Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousRange<const R>) { return Range::GetData(Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() requires (CContiguousRange< R>) { return Ranges::GetData(Base); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousRange<const R>) { return Ranges::GetData(Base); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< R>) { return Range::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const R>) { return Range::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< R>) { return Ranges::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const R>) { return Ranges::Num(Base); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() requires (requires( R Base) { Range::IsEmpty(Base); }) { return Range::IsEmpty(Base); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (requires(const R Base) { Range::IsEmpty(Base); }) { return Range::IsEmpty(Base); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() requires (requires( R Base) { Ranges::IsEmpty(Base); }) { return Ranges::IsEmpty(Base); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (requires(const R Base) { Ranges::IsEmpty(Base); }) { return Ranges::IsEmpty(Base); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr R& GetBase() & { return Base; }
|
||||
NODISCARD FORCEINLINE constexpr R&& GetBase() && { return MoveTemp(Base); }
|
||||
@ -125,12 +125,12 @@ static_assert( CView<TOwningView< IRange<IInputOrOutputIterator<int>>
|
||||
|
||||
static_assert(COutputRange<TOwningView<IRange<IOutputIterator<int&>>>, int>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename T>
|
||||
constexpr bool bEnableBorrowedRange<Range::TOwningView<T>> = bEnableBorrowedRange<T>;
|
||||
constexpr bool bEnableBorrowedRange<Ranges::TOwningView<T>> = bEnableBorrowedRange<T>;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** Creates A view adapter that includes all elements of a range. */
|
||||
template <CViewableRange R>
|
||||
@ -152,9 +152,9 @@ NODISCARD FORCEINLINE constexpr auto All(R&& InRange)
|
||||
/** Creates A view adapter that includes all elements of a range. */
|
||||
NODISCARD FORCEINLINE constexpr auto All()
|
||||
{
|
||||
using FClosure = decltype([]<CViewableRange R> requires (requires { Range::All(DeclVal<R>()); }) (R&& Base)
|
||||
using FClosure = decltype([]<CViewableRange R> requires (requires { Ranges::All(DeclVal<R>()); }) (R&& Base)
|
||||
{
|
||||
return Range::All(Forward<R>(Base));
|
||||
return Ranges::All(Forward<R>(Base));
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure>();
|
||||
@ -162,7 +162,7 @@ NODISCARD FORCEINLINE constexpr auto All()
|
||||
|
||||
/** A view adapter that includes all elements of a range. */
|
||||
template <CViewableRange R>
|
||||
using TAllView = decltype(Range::All(DeclVal<R>()));
|
||||
using TAllView = decltype(Ranges::All(DeclVal<R>()));
|
||||
|
||||
static_assert( CInputRange<TAllView<IRange< IInputIterator<int&>>>>);
|
||||
static_assert( CForwardRange<TAllView<IRange< IForwardIterator<int&>>>>);
|
||||
@ -176,7 +176,7 @@ static_assert( CView<TAllView< IRange<IInputOrOutputIterator<int>>>>)
|
||||
|
||||
static_assert(COutputRange<TAllView<IRange<IOutputIterator<int&>>>, int>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/AllView.h"
|
||||
#include "Ranges/View.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/AllView.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Range/TransformView.h"
|
||||
#include "Ranges/TransformView.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
@ -49,7 +49,7 @@ concept CAppendableContainer =
|
||||
);
|
||||
};
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** Constructs a non-view object from the elements of the range. */
|
||||
template <typename C, CInputRange R, typename... Ts> requires (!CView<C>)
|
||||
@ -64,7 +64,7 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args)
|
||||
|
||||
else if constexpr (CCommonRange<R> && CInputRange<R> && CConstructibleFrom<C, TRangeIterator<R>, TRangeSentinel<R>, Ts...>)
|
||||
{
|
||||
return C(Range::Begin(Range), Range::End(Range), Forward<Ts>(Args)...);
|
||||
return C(Ranges::Begin(Range), Ranges::End(Range), Forward<Ts>(Args)...);
|
||||
}
|
||||
|
||||
else if constexpr (CConstructibleFrom<C, Ts...> && CAppendableContainer<C, TRangeReference<R>>)
|
||||
@ -73,7 +73,7 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args)
|
||||
|
||||
if constexpr (CSizedRange<R> && CReservableContainer<C>)
|
||||
{
|
||||
Result.Reserve(Range::Num(Range));
|
||||
Result.Reserve(Ranges::Num(Range));
|
||||
}
|
||||
|
||||
for (TRangeReference<R> Element : Range)
|
||||
@ -108,7 +108,7 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args)
|
||||
{
|
||||
if constexpr (CInputRange<TRangeReference<C>>)
|
||||
{
|
||||
return Range::To<C>(Range::All(Range) | Range::Transform([]<typename T>(T&& Element) { return Range::To<TRangeElement<C>>(Forward<T>(Element)); }), Forward<Args>(Args)...);
|
||||
return Ranges::To<C>(Ranges::All(Range) | Ranges::Transform([]<typename T>(T&& Element) { return Ranges::To<TRangeElement<C>>(Forward<T>(Element)); }), Forward<Args>(Args)...);
|
||||
}
|
||||
|
||||
else static_assert(sizeof(R) == -1, "The container type is not constructible from a range");
|
||||
@ -121,12 +121,12 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args)
|
||||
{
|
||||
if constexpr (requires { C(DeclVal<R>(), DeclVal<Ts>()...); })
|
||||
{
|
||||
return Range::To<decltype(C(DeclVal<R>(), DeclVal<Ts>()...))>(Forward<R>(Range), Forward<Ts>(Args)...);
|
||||
return Ranges::To<decltype(C(DeclVal<R>(), DeclVal<Ts>()...))>(Forward<R>(Range), Forward<Ts>(Args)...);
|
||||
}
|
||||
|
||||
else if constexpr (requires { C(DeclVal<TRangeIterator<R>>(), DeclVal<TRangeSentinel<R>>(), DeclVal<Args>()...); })
|
||||
{
|
||||
return Range::To<decltype(C(DeclVal<TRangeIterator<R>>(), DeclVal<TRangeSentinel<R>>(), DeclVal<Args>()...))>(Forward<R>(Range), Forward<Ts>(Args)...);
|
||||
return Ranges::To<decltype(C(DeclVal<TRangeIterator<R>>(), DeclVal<TRangeSentinel<R>>(), DeclVal<Args>()...))>(Forward<R>(Range), Forward<Ts>(Args)...);
|
||||
}
|
||||
|
||||
else static_assert(sizeof(R) == -1, "The container type is not constructible from a range");
|
||||
@ -136,9 +136,9 @@ NODISCARD FORCEINLINE constexpr auto To(R&& Range, Ts&&... Args)
|
||||
template <typename C, typename... Ts> requires (!CView<C>)
|
||||
NODISCARD FORCEINLINE constexpr auto To(Ts&&... Args)
|
||||
{
|
||||
using FClosure = decltype([]<CInputRange R, typename... Us> requires (requires { Range::To<C>(DeclVal<R>(), DeclVal<Us>()...); }) (R&& Range, Us&&... Args)
|
||||
using FClosure = decltype([]<CInputRange R, typename... Us> requires (requires { Ranges::To<C>(DeclVal<R>(), DeclVal<Us>()...); }) (R&& Range, Us&&... Args)
|
||||
{
|
||||
return Range::To<C>(Forward<R>(Range), Forward<Us>(Args)...);
|
||||
return Ranges::To<C>(Forward<R>(Range), Forward<Us>(Args)...);
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure, TDecay<Ts>...>(Forward<Ts>(Args)...);
|
||||
@ -148,15 +148,15 @@ NODISCARD FORCEINLINE constexpr auto To(Ts&&... Args)
|
||||
template <template <typename...> typename C, typename... Ts>
|
||||
NODISCARD FORCEINLINE constexpr auto To(Ts&&... Args)
|
||||
{
|
||||
using FClosure = decltype([]<CInputRange R, typename... Us> requires (requires { Range::To<C>(DeclVal<R>(), DeclVal<Us>()...); }) (R&& Range, Us&&... Args)
|
||||
using FClosure = decltype([]<CInputRange R, typename... Us> requires (requires { Ranges::To<C>(DeclVal<R>(), DeclVal<Us>()...); }) (R&& Range, Us&&... Args)
|
||||
{
|
||||
return Range::To<C>(Forward<R>(Range), Forward<Us>(Args)...);
|
||||
return Ranges::To<C>(Forward<R>(Range), Forward<Us>(Args)...);
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure, TDecay<Ts>...>(Forward<Ts>(Args)...);
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Ranges/View.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Memory/Address.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
@ -11,7 +11,7 @@ NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** A view type that produces a view of no elements of a particular type. */
|
||||
template <CObject T>
|
||||
@ -39,12 +39,12 @@ static_assert( CCommonRange<TEmptyView<int>>);
|
||||
static_assert( CSizedRange<TEmptyView<int>>);
|
||||
static_assert( CView<TEmptyView<int>>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename T>
|
||||
constexpr bool bEnableBorrowedRange<Range::TEmptyView<T>> = true;
|
||||
constexpr bool bEnableBorrowedRange<Ranges::TEmptyView<T>> = true;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** A view type that contains exactly one element of a specified value. */
|
||||
template <CObject T> requires (CMoveConstructible<T>)
|
||||
@ -190,12 +190,12 @@ TIotaView(T, U) -> TIotaView<T, U>;
|
||||
static_assert(CForwardRange<TIotaView<int>>);
|
||||
static_assert( CView<TIotaView<int>>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename T, typename U>
|
||||
constexpr bool bEnableBorrowedRange<Range::TIotaView<T, U>> = true;
|
||||
constexpr bool bEnableBorrowedRange<Ranges::TIotaView<T, U>> = true;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** A view type that generates a sequence of elements by repeatedly producing the same value. Can be either bounded or unbounded. */
|
||||
template <CObject W, bool bIsUnreachable = true> requires (CMoveConstructible<W> && CSameAs<W, TRemoveCV<W>>)
|
||||
@ -307,9 +307,9 @@ static_assert( CCommonRange<TRepeatView<int, false>>);
|
||||
static_assert( CSizedRange<TRepeatView<int, false>>);
|
||||
static_assert( CView<TRepeatView<int, false>>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** A view of no elements of a particular type. */
|
||||
template <CObject T>
|
||||
@ -350,7 +350,7 @@ NODISCARD FORCEINLINE constexpr TRepeatView<TDecay<W>, false> Repeat(W&& Value,
|
||||
return TRepeatView<TDecay<W>, false>(Forward<W>(Value), Count);
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
@ -4,19 +4,19 @@
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/Invoke.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Memory/Address.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/AllView.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/Pipe.h"
|
||||
#include "Ranges/View.h"
|
||||
#include "Ranges/AllView.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/**
|
||||
* A view adapter that consists of the elements of a range that satisfies a predicate.
|
||||
@ -46,7 +46,7 @@ public:
|
||||
|
||||
NODISCARD FORCEINLINE constexpr FIterator Begin()
|
||||
{
|
||||
FIterator Iter(*this, Range::Begin(Base));
|
||||
FIterator Iter(*this, Ranges::Begin(Base));
|
||||
|
||||
do
|
||||
{
|
||||
@ -63,7 +63,7 @@ public:
|
||||
return Iter;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr FSentinel End() { return FSentinel(*this, Range::End(Base)); }
|
||||
NODISCARD FORCEINLINE constexpr FSentinel End() { return FSentinel(*this, Ranges::End(Base)); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() const& requires (CCopyConstructible<V>) { return Base; }
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() && { return MoveTemp(Base); }
|
||||
@ -161,9 +161,9 @@ static_assert(CBidirectionalRange<TFilterView<TAllView<IRange< IContiguousIter
|
||||
static_assert(CCommonRange<TFilterView<TAllView<ICommonRange<IForwardIterator<int>>>, bool(*)(int)>>);
|
||||
static_assert( CView<TFilterView<TAllView< IRange< IInputIterator<int>>>, bool(*)(int)>>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** Creates A view adapter that consists of the elements of a range that satisfies a predicate. */
|
||||
template <CViewableRange R, typename Pred> requires (requires { TFilterView(DeclVal<R>(), DeclVal<Pred>()); })
|
||||
@ -176,15 +176,15 @@ NODISCARD FORCEINLINE constexpr auto Filter(R&& Base, Pred&& Predicate)
|
||||
template <typename Pred>
|
||||
NODISCARD FORCEINLINE constexpr auto Filter(Pred&& Predicate)
|
||||
{
|
||||
using FClosure = decltype([]<CViewableRange R, typename T> requires (requires { Range::Filter(DeclVal<R>(), DeclVal<T>()); }) (R&& Base, T&& Predicate)
|
||||
using FClosure = decltype([]<CViewableRange R, typename T> requires (requires { Ranges::Filter(DeclVal<R>(), DeclVal<T>()); }) (R&& Base, T&& Predicate)
|
||||
{
|
||||
return Range::Filter(Forward<R>(Base), Forward<T>(Predicate));
|
||||
return Ranges::Filter(Forward<R>(Base), Forward<T>(Predicate));
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure, TDecay<Pred>>(Forward<Pred>(Predicate));
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
@ -3,19 +3,19 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/MoveIterator.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/AllView.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/MoveIterator.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/Pipe.h"
|
||||
#include "Ranges/View.h"
|
||||
#include "Ranges/AllView.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/**
|
||||
* A view adapter which dereferences to a rvalue reference.
|
||||
@ -36,34 +36,34 @@ public:
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() requires (!CSimpleView<V>)
|
||||
{
|
||||
return MakeMoveIterator(Range::Begin(Base));
|
||||
return MakeMoveIterator(Ranges::Begin(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const V>)
|
||||
{
|
||||
return MakeMoveIterator(Range::Begin(Base));
|
||||
return MakeMoveIterator(Ranges::Begin(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End() requires (!CSimpleView<V>)
|
||||
{
|
||||
if constexpr (CCommonRange<V>)
|
||||
{
|
||||
return MakeMoveIterator(Range::End(Base));
|
||||
return MakeMoveIterator(Ranges::End(Base));
|
||||
}
|
||||
else return MakeMoveSentinel(Range::End(Base));
|
||||
else return MakeMoveSentinel(Ranges::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const V>)
|
||||
{
|
||||
if constexpr (CCommonRange<V>)
|
||||
{
|
||||
return MakeMoveIterator(Range::End(Base));
|
||||
return MakeMoveIterator(Ranges::End(Base));
|
||||
}
|
||||
else return MakeMoveSentinel(Range::End(Base));
|
||||
else return MakeMoveSentinel(Ranges::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< V>) { return Range::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const V>) { return Range::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< V>) { return Ranges::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const V>) { return Ranges::Num(Base); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() const& requires (CCopyConstructible<V>) { return Base; }
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() && { return MoveTemp(Base); }
|
||||
@ -86,12 +86,12 @@ static_assert( CRandomAccessRange<TMoveView<TAllView<IRange< IContiguousIterat
|
||||
static_assert(CCommonRange<TMoveView<TAllView<ICommonRange<IForwardIterator<int>>>>>);
|
||||
static_assert( CView<TMoveView<TAllView< IRange< IInputIterator<int>>>>>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename T>
|
||||
constexpr bool bEnableBorrowedRange<Range::TMoveView<T>> = bEnableBorrowedRange<T>;
|
||||
constexpr bool bEnableBorrowedRange<Ranges::TMoveView<T>> = bEnableBorrowedRange<T>;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** Creates A view adapter that dereferences to a rvalue reference. */
|
||||
template <CViewableRange R> requires (requires { TMoveView(DeclVal<R>()); })
|
||||
@ -103,15 +103,15 @@ NODISCARD FORCEINLINE constexpr auto Move(R&& Base)
|
||||
/** Creates A view adapter that dereferences to a rvalue reference. */
|
||||
NODISCARD FORCEINLINE constexpr auto Move()
|
||||
{
|
||||
using FClosure = decltype([]<CViewableRange R> requires (requires { Range::Move(DeclVal<R>()); }) (R&& Base)
|
||||
using FClosure = decltype([]<CViewableRange R> requires (requires { Ranges::Move(DeclVal<R>()); }) (R&& Base)
|
||||
{
|
||||
return Range::Move(Forward<R>(Base));
|
||||
return Ranges::Move(Forward<R>(Base));
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure>();
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Templates/Tuple.h"
|
||||
#include "Templates/Invoke.h"
|
||||
#include "Templates/Utility.h"
|
||||
@ -11,7 +11,7 @@ NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/**
|
||||
* An interface class template for defining a range adaptor closure.
|
||||
@ -139,7 +139,7 @@ NODISCARD FORCEINLINE constexpr auto operator|(T&& LHS, U&& RHS)
|
||||
return TPipeClosure<TRemoveCVRef<T>, TRemoveCVRef<U>>(Forward<T>(LHS), Forward<U>(RHS));
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
14
Redcraft.Utility/Source/Public/Ranges/Ranges.h
Normal file
14
Redcraft.Utility/Source/Public/Ranges/Ranges.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/View.h"
|
||||
#include "Ranges/Conversion.h"
|
||||
#include "Ranges/Factory.h"
|
||||
#include "Ranges/Pipe.h"
|
||||
#include "Ranges/AllView.h"
|
||||
#include "Ranges/MoveView.h"
|
||||
#include "Ranges/FilterView.h"
|
||||
#include "Ranges/TransformView.h"
|
||||
#include "Ranges/TakeView.h"
|
||||
#include "Ranges/TakeWhileView.h"
|
@ -3,20 +3,20 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/CountedIterator.h"
|
||||
#include "Numeric/Math.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/AllView.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/CountedIterator.h"
|
||||
#include "Numerics/Math.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/Pipe.h"
|
||||
#include "Ranges/View.h"
|
||||
#include "Ranges/AllView.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/**
|
||||
* A view adapter that includes a specified number of elements from the beginning of a range.
|
||||
@ -42,11 +42,11 @@ public:
|
||||
{
|
||||
if constexpr (CRandomAccessRange<V>)
|
||||
{
|
||||
return Range::Begin(Base);
|
||||
return Ranges::Begin(Base);
|
||||
}
|
||||
else return MakeCountedIterator(Range::Begin(Base), Num());
|
||||
else return MakeCountedIterator(Ranges::Begin(Base), Num());
|
||||
}
|
||||
else return MakeCountedIterator(Range::Begin(Base), Count);
|
||||
else return MakeCountedIterator(Ranges::Begin(Base), Count);
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const V>)
|
||||
@ -55,11 +55,11 @@ public:
|
||||
{
|
||||
if constexpr (CRandomAccessRange<const V>)
|
||||
{
|
||||
return Range::Begin(Base);
|
||||
return Ranges::Begin(Base);
|
||||
}
|
||||
else return MakeCountedIterator(Range::Begin(Base), Num());
|
||||
else return MakeCountedIterator(Ranges::Begin(Base), Num());
|
||||
}
|
||||
else return MakeCountedIterator(Range::Begin(Base), Count);
|
||||
else return MakeCountedIterator(Ranges::Begin(Base), Count);
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End() requires (!CSimpleView<V>)
|
||||
@ -68,11 +68,11 @@ public:
|
||||
{
|
||||
if constexpr (CRandomAccessRange<V>)
|
||||
{
|
||||
return Range::Begin(Base) + Num();
|
||||
return Ranges::Begin(Base) + Num();
|
||||
}
|
||||
else return DefaultSentinel;
|
||||
}
|
||||
else return FSentinelImpl<false>(Range::End(Base));
|
||||
else return FSentinelImpl<false>(Ranges::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const V>)
|
||||
@ -81,15 +81,15 @@ public:
|
||||
{
|
||||
if constexpr (CRandomAccessRange<const V>)
|
||||
{
|
||||
return Range::Begin(Base) + Num();
|
||||
return Ranges::Begin(Base) + Num();
|
||||
}
|
||||
else return DefaultSentinel;
|
||||
}
|
||||
else return FSentinelImpl<true>(Range::End(Base));
|
||||
else return FSentinelImpl<true>(Ranges::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< V>) { return Math::Min(Range::Num(Base), Count); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const V>) { return Math::Min(Range::Num(Base), Count); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< V>) { return Math::Min(Ranges::Num(Base), Count); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const V>) { return Math::Min(Ranges::Num(Base), Count); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() const& requires (CCopyConstructible<V>) { return Base; }
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() && { return MoveTemp(Base); }
|
||||
@ -154,12 +154,12 @@ static_assert( CView<TTakeView<TAllView< IRange<IInputOrOutputIterator
|
||||
|
||||
static_assert(COutputRange<TTakeView<TAllView<IRange<IOutputIterator<int&>>>>, int>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename T>
|
||||
constexpr bool bEnableBorrowedRange<Range::TTakeView<T>> = bEnableBorrowedRange<T>;
|
||||
constexpr bool bEnableBorrowedRange<Ranges::TTakeView<T>> = bEnableBorrowedRange<T>;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** Creates A view adapter that includes a specified number of elements from the beginning of a range. */
|
||||
template <CViewableRange R> requires (requires { TTakeView(DeclVal<R>(), DeclVal<size_t>()); })
|
||||
@ -171,15 +171,15 @@ NODISCARD FORCEINLINE constexpr auto Take(R&& Base, size_t Count)
|
||||
/** Creates A view adapter that includes a specified number of elements from the beginning of a range. */
|
||||
NODISCARD FORCEINLINE constexpr auto Take(size_t Count)
|
||||
{
|
||||
using FClosure = decltype([]<CViewableRange R> requires (requires { Range::Take(DeclVal<R>(), DeclVal<size_t>()); }) (R&& Base, size_t Count)
|
||||
using FClosure = decltype([]<CViewableRange R> requires (requires { Ranges::Take(DeclVal<R>(), DeclVal<size_t>()); }) (R&& Base, size_t Count)
|
||||
{
|
||||
return Range::Take(Forward<R>(Base), Count);
|
||||
return Ranges::Take(Forward<R>(Base), Count);
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure, size_t>(Count);
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
@ -3,20 +3,20 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/CountedIterator.h"
|
||||
#include "Numeric/Math.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/AllView.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/CountedIterator.h"
|
||||
#include "Numerics/Math.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/Pipe.h"
|
||||
#include "Ranges/View.h"
|
||||
#include "Ranges/AllView.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/**
|
||||
* A view adapter that includes elements that satisfy the predicate from the beginning of the range.
|
||||
@ -41,22 +41,22 @@ public:
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() requires (!CSimpleView<V>)
|
||||
{
|
||||
return Range::Begin(Base);
|
||||
return Ranges::Begin(Base);
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const V> && CPredicate<const Pred&, TRangeReference<const V>>)
|
||||
{
|
||||
return Range::Begin(Base);
|
||||
return Ranges::Begin(Base);
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End() requires (!CSimpleView<V>)
|
||||
{
|
||||
return FSentinelImpl<false>(Range::End(Base), AddressOf(Predicate));
|
||||
return FSentinelImpl<false>(Ranges::End(Base), AddressOf(Predicate));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const V> && CPredicate<const Pred&, TRangeReference<const V>>)
|
||||
{
|
||||
return FSentinelImpl<true>(Range::End(Base), AddressOf(Predicate));
|
||||
return FSentinelImpl<true>(Ranges::End(Base), AddressOf(Predicate));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() const& requires (CCopyConstructible<V>) { return Base; }
|
||||
@ -119,9 +119,9 @@ static_assert(CView<TTakeWhileView<TAllView<IRange<IInputIterator<int>>>, bool(*
|
||||
|
||||
static_assert(COutputRange<TTakeWhileView<TAllView<IRange<IForwardIterator<int&>>>, bool(*)(int)>, int>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** Creates A view adapter that includes elements that satisfy the predicate from the beginning of the range. */
|
||||
template <CViewableRange R, typename Pred> requires (requires { TTakeWhileView(DeclVal<R>(), DeclVal<Pred>()); })
|
||||
@ -134,15 +134,15 @@ NODISCARD FORCEINLINE constexpr auto TakeWhile(R&& Base, Pred&& Predicate)
|
||||
template <typename Pred>
|
||||
NODISCARD FORCEINLINE constexpr auto TakeWhile(Pred&& Predicate)
|
||||
{
|
||||
using FClosure = decltype([]<CViewableRange R, typename T> requires (requires { Range::TakeWhile(DeclVal<R>(), DeclVal<T>()); }) (R&& Base, T&& Predicate)
|
||||
using FClosure = decltype([]<CViewableRange R, typename T> requires (requires { Ranges::TakeWhile(DeclVal<R>(), DeclVal<T>()); }) (R&& Base, T&& Predicate)
|
||||
{
|
||||
return Range::TakeWhile(Forward<R>(Base), Forward<T>(Predicate));
|
||||
return Ranges::TakeWhile(Forward<R>(Base), Forward<T>(Predicate));
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure, TDecay<Pred>>(Forward<Pred>(Predicate));
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Range/View.h"
|
||||
#include "Range/Pipe.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/AllView.h"
|
||||
#include "Ranges/View.h"
|
||||
#include "Ranges/Pipe.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/AllView.h"
|
||||
#include "Templates/Invoke.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
@ -13,7 +13,7 @@ NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/**
|
||||
* A view adapter of a sequence that applies a transformation function to each element.
|
||||
@ -39,36 +39,36 @@ public:
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin()
|
||||
{
|
||||
return FIteratorImpl<false>(*this, Range::Begin(Base));
|
||||
return FIteratorImpl<false>(*this, Ranges::Begin(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const V> && CRegularInvocable<const F&, TRangeReference<const V>>)
|
||||
{
|
||||
return FIteratorImpl<true>(*this, Range::Begin(Base));
|
||||
return FIteratorImpl<true>(*this, Ranges::Begin(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End()
|
||||
{
|
||||
if constexpr (CCommonRange<V>)
|
||||
{
|
||||
return FIteratorImpl<false>(*this, Range::End(Base));
|
||||
return FIteratorImpl<false>(*this, Ranges::End(Base));
|
||||
}
|
||||
|
||||
else return FSentinelImpl<false>(*this, Range::End(Base));
|
||||
else return FSentinelImpl<false>(*this, Ranges::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const V> && CRegularInvocable<const F&, TRangeReference<const V>>)
|
||||
{
|
||||
if constexpr (CCommonRange<const V>)
|
||||
{
|
||||
return FIteratorImpl<true>(*this, Range::End(Base));
|
||||
return FIteratorImpl<true>(*this, Ranges::End(Base));
|
||||
}
|
||||
|
||||
else return FSentinelImpl<true>(*this, Range::End(Base));
|
||||
else return FSentinelImpl<true>(*this, Ranges::End(Base));
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< V>) { return Range::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const V>) { return Range::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CSizedRange< V>) { return Ranges::Num(Base); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CSizedRange<const V>) { return Ranges::Num(Base); }
|
||||
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() const& requires (CCopyConstructible<V>) { return Base; }
|
||||
NODISCARD FORCEINLINE constexpr V GetBase() && { return MoveTemp(Base); }
|
||||
@ -206,9 +206,9 @@ static_assert( CView<TTransformView<TAllView< IRange< IInputIterator
|
||||
|
||||
static_assert(COutputRange<TTransformView<TAllView<IRange<IForwardIterator<int>>>, int&(*)(int)>, int>);
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** Creates A view adapter of a sequence that applies a transformation function to each element. */
|
||||
template <CViewableRange R, typename F> requires (requires { TTransformView(DeclVal<R>(), DeclVal<F>()); })
|
||||
@ -221,15 +221,15 @@ NODISCARD FORCEINLINE constexpr auto Transform(R&& Base, F&& Func)
|
||||
template <typename F>
|
||||
NODISCARD FORCEINLINE constexpr auto Transform(F&& Func)
|
||||
{
|
||||
using FClosure = decltype([]<CViewableRange R, typename T> requires (requires { Range::Transform(DeclVal<R>(), DeclVal<T>()); }) (R&& Base, T&& Func)
|
||||
using FClosure = decltype([]<CViewableRange R, typename T> requires (requires { Ranges::Transform(DeclVal<R>(), DeclVal<T>()); }) (R&& Base, T&& Func)
|
||||
{
|
||||
return Range::Transform(Forward<R>(Base), Forward<T>(Func));
|
||||
return Ranges::Transform(Forward<R>(Base), Forward<T>(Func));
|
||||
});
|
||||
|
||||
return TAdaptorClosure<FClosure, TDecay<F>>(Forward<F>(Func));
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
@ -3,10 +3,10 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/ReverseIterator.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
@ -20,7 +20,7 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
||||
template <typename R>
|
||||
inline constexpr bool bEnableBorrowedRange = false;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** @return The iterator to the beginning of a container. */
|
||||
template <typename T> requires ((CLValueReference<T> || bEnableBorrowedRange<TRemoveCVRef<T>>)
|
||||
@ -45,12 +45,12 @@ NODISCARD FORCEINLINE constexpr const T* Begin(initializer_list<T>& Container)
|
||||
return Container.begin();
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename R>
|
||||
using TRangeIterator = decltype(Range::Begin(DeclVal<R&>()));
|
||||
using TRangeIterator = decltype(Ranges::Begin(DeclVal<R&>()));
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** @return The iterator to the end of a container. */
|
||||
template <typename T> requires ((CLValueReference<T> || bEnableBorrowedRange<TRemoveCVRef<T>>)
|
||||
@ -75,13 +75,13 @@ NODISCARD FORCEINLINE constexpr const T* End(initializer_list<T>& Container)
|
||||
return Container.end();
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename R>
|
||||
using TRangeSentinel = decltype(Range::End(DeclVal<R&>()));
|
||||
using TRangeSentinel = decltype(Ranges::End(DeclVal<R&>()));
|
||||
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** @return The reverse iterator to the beginning of a container. */
|
||||
template <typename T> requires ((CLValueReference<T> || bEnableBorrowedRange<TRemoveCVRef<T>>)
|
||||
@ -97,12 +97,12 @@ template <typename T> requires ((CLValueReference<T> || bEnableBorrowedRange<TRe
|
||||
&& (CSameAs<TRangeIterator<T>, TRangeSentinel<T>> && CBidirectionalIterator<TRangeIterator<T>>))
|
||||
NODISCARD FORCEINLINE constexpr auto RBegin(T&& Container)
|
||||
{
|
||||
return MakeReverseIterator(Range::End(Forward<T>(Container)));
|
||||
return MakeReverseIterator(Ranges::End(Forward<T>(Container)));
|
||||
}
|
||||
|
||||
/** @return The reverse iterator to the end of a container. */
|
||||
template <typename T> requires ((CLValueReference<T> || bEnableBorrowedRange<TRemoveCVRef<T>>)
|
||||
&& requires(T&& Container) { { Container.REnd() } -> CSentinelFor<decltype(Range::RBegin(DeclVal<T&>()))>; })
|
||||
&& requires(T&& Container) { { Container.REnd() } -> CSentinelFor<decltype(Ranges::RBegin(DeclVal<T&>()))>; })
|
||||
NODISCARD FORCEINLINE constexpr auto REnd(T&& Container)
|
||||
{
|
||||
return Container.REnd();
|
||||
@ -110,14 +110,14 @@ NODISCARD FORCEINLINE constexpr auto REnd(T&& Container)
|
||||
|
||||
/** Overloads the REnd algorithm for synthesized. */
|
||||
template <typename T> requires ((CLValueReference<T> || bEnableBorrowedRange<TRemoveCVRef<T>>)
|
||||
&& !requires(T&& Container) { { Container.REnd() } -> CSentinelFor<decltype(Range::RBegin(DeclVal<T&>()))>; }
|
||||
&& !requires(T&& Container) { { Container.REnd() } -> CSentinelFor<decltype(Ranges::RBegin(DeclVal<T&>()))>; }
|
||||
&& (CSameAs<TRangeIterator<T>, TRangeSentinel<T>> && CBidirectionalIterator<TRangeIterator<T>>))
|
||||
NODISCARD FORCEINLINE constexpr auto REnd(T&& Container)
|
||||
{
|
||||
return MakeReverseIterator(Range::Begin(Forward<T>(Container)));
|
||||
return MakeReverseIterator(Ranges::Begin(Forward<T>(Container)));
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename R>
|
||||
using TRangeElement = TIteratorElement<TRangeIterator<R>>;
|
||||
@ -131,7 +131,7 @@ using TRangeReference = TIteratorReference<TRangeIterator<R>>;
|
||||
template <typename R>
|
||||
using TRangeRValueReference = TIteratorRValueReference<TRangeIterator<R>>;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** @return The pointer to the container element storage. */
|
||||
template <typename T> requires ((CLValueReference<T> || bEnableBorrowedRange<TRemoveCVRef<T>>)
|
||||
@ -144,19 +144,19 @@ NODISCARD FORCEINLINE constexpr auto GetData(T&& Container)
|
||||
/** Overloads the GetData algorithm for synthesized. */
|
||||
template <typename T> requires ((CLValueReference<T> || bEnableBorrowedRange<TRemoveCVRef<T>>)
|
||||
&& !requires(T&& Container) { { Container.GetData() } -> CSameAs<TAddPointer<TRangeReference<T>>>; }
|
||||
&& requires(T&& Container) { { Range::Begin(Forward<T>(Container)) } -> CContiguousIterator; })
|
||||
&& requires(T&& Container) { { Ranges::Begin(Forward<T>(Container)) } -> CContiguousIterator; })
|
||||
NODISCARD FORCEINLINE constexpr auto GetData(T&& Container)
|
||||
{
|
||||
return ToAddress(Range::Begin(Forward<T>(Container)));
|
||||
return ToAddress(Ranges::Begin(Forward<T>(Container)));
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
/** Disable the CSizedRange concept for specific types. */
|
||||
template <typename R>
|
||||
inline constexpr bool bDisableSizedRange = false;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** @return The number of elements in the container. */
|
||||
template <typename T> requires (!bDisableSizedRange<TRemoveCVRef<T>>
|
||||
@ -180,7 +180,7 @@ template <typename T> requires (!bDisableSizedRange<TRemoveCVRef<T>>
|
||||
&& CSizedSentinelFor<TRangeSentinel<T>, TRangeIterator<T>> && CForwardIterator<TRangeIterator<T>>)
|
||||
NODISCARD FORCEINLINE constexpr size_t Num(T&& Container)
|
||||
{
|
||||
return Range::End(Forward<T>(Container)) - Range::Begin(Forward<T>(Container));
|
||||
return Ranges::End(Forward<T>(Container)) - Ranges::Begin(Forward<T>(Container));
|
||||
}
|
||||
|
||||
/** Overloads the Num algorithm for initializer_list. */
|
||||
@ -203,7 +203,7 @@ template <typename T> requires ((CBoundedArray<TRemoveReference<T>>
|
||||
&& !requires(T&& Container) { { Container.IsEmpty() } -> CBooleanTestable; })
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty(T&& Container)
|
||||
{
|
||||
return Range::Num(Forward<T>(Container)) == 0;
|
||||
return Ranges::Num(Forward<T>(Container)) == 0;
|
||||
}
|
||||
|
||||
/** Overloads the IsEmpty algorithm for synthesized. */
|
||||
@ -213,10 +213,10 @@ template <typename T> requires (!CBoundedArray<TRemoveReference<T>>
|
||||
&& CForwardIterator<TRangeIterator<T>>)
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty(T&& Container)
|
||||
{
|
||||
return Range::End(Forward<T>(Container)) == Range::Begin(Forward<T>(Container));
|
||||
return Ranges::End(Forward<T>(Container)) == Ranges::Begin(Forward<T>(Container));
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
/**
|
||||
* A concept specifies a type is a range.
|
||||
@ -261,7 +261,7 @@ concept CBorrowedRange = CRange<R> && (CLValueReference<R> || bEnableBorrowedRan
|
||||
|
||||
/**
|
||||
* A concept specifies a type is a sized range.
|
||||
* Indicates the expression 'Range::Num(Range)' can get the size of the range at constant time
|
||||
* Indicates the expression 'Ranges::Num(Range)' can get the size of the range at constant time
|
||||
* without modifying the range object. Modifying the range usually occurs when the iterator of
|
||||
* the range is an input iterator. Indirect calculation of the range by obtaining the iterator
|
||||
* may cause the range to become invalid, that is, the iterator cannot be obtained again.
|
||||
@ -270,7 +270,7 @@ template <typename R>
|
||||
concept CSizedRange = CRange<R>
|
||||
&& requires(R Range)
|
||||
{
|
||||
{ Range::Num(Range) } -> CConvertibleTo<size_t>;
|
||||
{ Ranges::Num(Range) } -> CConvertibleTo<size_t>;
|
||||
};
|
||||
|
||||
/** This is an example of a sized range type, indicate the traits that define a sized range type. */
|
||||
@ -337,7 +337,7 @@ template <typename R>
|
||||
concept CContiguousRange = CRandomAccessRange<R> && CContiguousIterator<TRangeIterator<R>>
|
||||
&& requires(R& Range)
|
||||
{
|
||||
{ Range::GetData(Range) } -> CSameAs<TAddPointer<TRangeReference<R>>>;
|
||||
{ Ranges::GetData(Range) } -> CSameAs<TAddPointer<TRangeReference<R>>>;
|
||||
};
|
||||
|
||||
/** This is an example of a contiguous range type, indicate the traits that define a contiguous range type. */
|
||||
@ -354,7 +354,7 @@ struct IContiguousRange /* : IRange<I, S> */
|
||||
/**
|
||||
* Get the pointer to the container element storage.
|
||||
* The function is optional if the range size can be computed indirectly from the iterator.
|
||||
* If the function is provided, then the expression 'ToAddress(Range::Begin(Range)) == Range::GetData(Range)'
|
||||
* If the function is provided, then the expression 'ToAddress(Ranges::Begin(Range)) == Ranges::GetData(Range)'
|
||||
* must be satisfied to always be true.
|
||||
* If the function is const, it means that the const IContiguousRange satisfies CContiguousRange.
|
||||
*/
|
@ -3,18 +3,18 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Templates/Utility.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/ReverseIterator.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/ReverseIterator.h"
|
||||
#include "Memory/Address.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Ranges/Utility.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** An interface class template for defining a view. Not directly instantiable. */
|
||||
template <CClass T> requires (CSameAs<T, TRemoveCV<T>>)
|
||||
@ -23,43 +23,43 @@ class IBasicViewInterface
|
||||
public:
|
||||
|
||||
/** @return The pointer to the underlying element storage. */
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() requires (CContiguousIterator<TRangeIterator< T>>) { return ToAddress(Range::Begin(static_cast< T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousIterator<TRangeIterator<const T>>) { return ToAddress(Range::Begin(static_cast<const T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() requires (CContiguousIterator<TRangeIterator< T>>) { return ToAddress(Ranges::Begin(static_cast< T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto GetData() const requires (CContiguousIterator<TRangeIterator<const T>>) { return ToAddress(Ranges::Begin(static_cast<const T&>(*this))); }
|
||||
|
||||
/** @return The reverse iterator to the first or end element. */
|
||||
NODISCARD FORCEINLINE constexpr auto RBegin() requires (CBidirectionalRange< T> && CCommonRange< T>) { return MakeReverseIterator(Range::End (static_cast< T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto REnd() requires (CBidirectionalRange< T> && CCommonRange< T>) { return MakeReverseIterator(Range::Begin(static_cast< T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto RBegin() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return MakeReverseIterator(Range::End (static_cast<const T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto REnd() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return MakeReverseIterator(Range::Begin(static_cast<const T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto RBegin() requires (CBidirectionalRange< T> && CCommonRange< T>) { return MakeReverseIterator(Ranges::End (static_cast< T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto REnd() requires (CBidirectionalRange< T> && CCommonRange< T>) { return MakeReverseIterator(Ranges::Begin(static_cast< T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto RBegin() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return MakeReverseIterator(Ranges::End (static_cast<const T&>(*this))); }
|
||||
NODISCARD FORCEINLINE constexpr auto REnd() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return MakeReverseIterator(Ranges::Begin(static_cast<const T&>(*this))); }
|
||||
|
||||
/** @return The number of elements in the container. */
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CForwardRange< T> && CSizedSentinelFor<TRangeSentinel< T>, TRangeIterator< T>>) { T& Derived = static_cast< T&>(*this); return Range::End(Derived) - Range::Begin(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CForwardRange<const T> && CSizedSentinelFor<TRangeSentinel<const T>, TRangeIterator<const T>>) { const T& Derived = static_cast<const T&>(*this); return Range::End(Derived) - Range::Begin(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() requires (CForwardRange< T> && CSizedSentinelFor<TRangeSentinel< T>, TRangeIterator< T>>) { T& Derived = static_cast< T&>(*this); return Ranges::End(Derived) - Ranges::Begin(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr size_t Num() const requires (CForwardRange<const T> && CSizedSentinelFor<TRangeSentinel<const T>, TRangeIterator<const T>>) { const T& Derived = static_cast<const T&>(*this); return Ranges::End(Derived) - Ranges::Begin(Derived); }
|
||||
|
||||
/** @return true if the container is empty, false otherwise. */
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() requires (CSizedRange< T> || CForwardRange< T>) { T& Derived = static_cast< T&>(*this); if constexpr (CSizedRange< T>) return Range::Num(Derived) == 0; else return Range::Begin(Derived) == Range::End(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (CSizedRange<const T> || CForwardRange<const T>) { const T& Derived = static_cast<const T&>(*this); if constexpr (CSizedRange<const T>) return Range::Num(Derived) == 0; else return Range::Begin(Derived) == Range::End(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() requires (CSizedRange< T> || CForwardRange< T>) { T& Derived = static_cast< T&>(*this); if constexpr (CSizedRange< T>) return Ranges::Num(Derived) == 0; else return Ranges::Begin(Derived) == Ranges::End(Derived); }
|
||||
NODISCARD FORCEINLINE constexpr bool IsEmpty() const requires (CSizedRange<const T> || CForwardRange<const T>) { const T& Derived = static_cast<const T&>(*this); if constexpr (CSizedRange<const T>) return Ranges::Num(Derived) == 0; else return Ranges::Begin(Derived) == Ranges::End(Derived); }
|
||||
|
||||
/** @return true if the container is empty, false otherwise. */
|
||||
NODISCARD FORCEINLINE constexpr explicit operator bool() requires (requires { Range::IsEmpty(DeclVal< T&>()); }) { return !Range::IsEmpty(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr explicit operator bool() const requires (requires { Range::IsEmpty(DeclVal<const T&>()); }) { return !Range::IsEmpty(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr explicit operator bool() requires (requires { Ranges::IsEmpty(DeclVal< T&>()); }) { return !Ranges::IsEmpty(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr explicit operator bool() const requires (requires { Ranges::IsEmpty(DeclVal<const T&>()); }) { return !Ranges::IsEmpty(static_cast<const T&>(*this)); }
|
||||
|
||||
/** @return The reference to the requested element. */
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) operator[](size_t Index) requires (CRandomAccessRange< T>) { return Range::Begin(static_cast< T&>(*this))[Index]; }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) operator[](size_t Index) const requires (CRandomAccessRange<const T>) { return Range::Begin(static_cast<const T&>(*this))[Index]; }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) operator[](size_t Index) requires (CRandomAccessRange< T>) { return Ranges::Begin(static_cast< T&>(*this))[Index]; }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) operator[](size_t Index) const requires (CRandomAccessRange<const T>) { return Ranges::Begin(static_cast<const T&>(*this))[Index]; }
|
||||
|
||||
/** @return The reference to the first or last element. */
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Front() requires (CForwardRange< T>) { return *Range::Begin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Front() const requires (CForwardRange<const T>) { return *Range::Begin(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Back() requires (CBidirectionalRange< T> && CCommonRange< T>) { return *Range::RBegin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Back() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return *Range::RBegin(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Front() requires (CForwardRange< T>) { return *Ranges::Begin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Front() const requires (CForwardRange<const T>) { return *Ranges::Begin(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Back() requires (CBidirectionalRange< T> && CCommonRange< T>) { return *Ranges::RBegin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr decltype(auto) Back() const requires (CBidirectionalRange<const T> && CCommonRange<const T>) { return *Ranges::RBegin(static_cast<const T&>(*this)); }
|
||||
|
||||
// ~Begin ENABLE_RANGE_BASED_FOR_LOOP_SUPPORT.
|
||||
|
||||
NODISCARD FORCEINLINE constexpr auto begin() requires (CRange< T>) { return Range::Begin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto end() requires (CRange< T>) { return Range::End (static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto begin() const requires (CRange<const T>) { return Range::Begin(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto end() const requires (CRange<const T>) { return Range::End (static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto begin() requires (CRange< T>) { return Ranges::Begin(static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto end() requires (CRange< T>) { return Ranges::End (static_cast< T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto begin() const requires (CRange<const T>) { return Ranges::Begin(static_cast<const T&>(*this)); }
|
||||
NODISCARD FORCEINLINE constexpr auto end() const requires (CRange<const T>) { return Ranges::End (static_cast<const T&>(*this)); }
|
||||
|
||||
// ~End ENABLE_RANGE_BASED_FOR_LOOP_SUPPORT.
|
||||
|
||||
@ -75,14 +75,14 @@ private:
|
||||
friend T;
|
||||
};
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
/**
|
||||
* A concept specifies that a range is a view, that is, it has constant time copy, move and assignment.
|
||||
* Specify, a view can be movable only but not copyable, or it can be both movable and copyable.
|
||||
*/
|
||||
template <typename V>
|
||||
concept CView = CRange<V> && CMovable<V> && CDerivedFrom<V, Range::IBasicViewInterface<TRemoveCVRef<V>>>;
|
||||
concept CView = CRange<V> && CMovable<V> && CDerivedFrom<V, Ranges::IBasicViewInterface<TRemoveCVRef<V>>>;
|
||||
|
||||
NAMESPACE_PRIVATE_BEGIN
|
||||
|
||||
@ -91,7 +91,7 @@ template <typename T> struct TIsInitializerList<initializer_list<T>> : FTrue {
|
||||
|
||||
NAMESPACE_PRIVATE_END
|
||||
|
||||
/** A concept specifies that a viewable range that can be converted into a view through Range::All. */
|
||||
/** A concept specifies that a viewable range that can be converted into a view through Ranges::All. */
|
||||
template <typename R>
|
||||
concept CViewableRange = CRange<R>
|
||||
&& ((CView<TRemoveCVRef<R>> && CConstructibleFrom<TRemoveCVRef<R>, R>)
|
||||
@ -104,7 +104,7 @@ concept CSimpleView = CView<V> && CRange<const V>
|
||||
&& CSameAs<TRangeIterator<V>, TRangeIterator<const V>>
|
||||
&& CSameAs<TRangeSentinel<V>, TRangeSentinel<const V>>;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** A simple view that combines an iterator-sentinel pair into a view. */
|
||||
template <CInputOrOutputIterator I, CSentinelFor<I> S = I>
|
||||
@ -137,12 +137,12 @@ private:
|
||||
template <CInputOrOutputIterator I, CSentinelFor<I> S>
|
||||
TRangeView(I, S) -> TRangeView<I, S>;
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
template <typename I, typename S>
|
||||
constexpr bool bEnableBorrowedRange<Range::TRangeView<I, S>> = true;
|
||||
constexpr bool bEnableBorrowedRange<Ranges::TRangeView<I, S>> = true;
|
||||
|
||||
NAMESPACE_BEGIN(Range)
|
||||
NAMESPACE_BEGIN(Ranges)
|
||||
|
||||
/** Creates A simple view that combines an iterator-sentinel pair. */
|
||||
template <CInputOrOutputIterator I, CSentinelFor<I> S = I>
|
||||
@ -151,7 +151,7 @@ NODISCARD FORCEINLINE constexpr TRangeView<I, S> View(I First, S Last)
|
||||
return TRangeView<I, S>(MoveTemp(First), Last);
|
||||
}
|
||||
|
||||
NAMESPACE_END(Range)
|
||||
NAMESPACE_END(Ranges)
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
@ -900,7 +900,7 @@ struct TStringObjectFormatter
|
||||
}
|
||||
|
||||
// Format the container value by format string.
|
||||
else if constexpr (requires { Range::Begin(Object); Range::End(Object); })
|
||||
else if constexpr (requires { Ranges::Begin(Object); Ranges::End(Object); })
|
||||
{
|
||||
auto FillAndAlign = ParseFillAndAlign();
|
||||
|
||||
@ -951,7 +951,7 @@ struct TStringObjectFormatter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Range::Begin(Object) == Range::End(Object))
|
||||
if (Ranges::Begin(Object) == Ranges::End(Object))
|
||||
{
|
||||
Result += Begin;
|
||||
Result += End;
|
||||
@ -966,7 +966,7 @@ struct TStringObjectFormatter
|
||||
struct { TStringView<T> Fmt; } ElementParam = { Subfmt };
|
||||
|
||||
// It is assumed that if the first element is successfully formatted, all elements will succeed.
|
||||
bool bIsSuccessful = TStringObjectFormatter::Do(Buffer, *Range::Begin(Object), ElementParam);
|
||||
bool bIsSuccessful = TStringObjectFormatter::Do(Buffer, *Ranges::Begin(Object), ElementParam);
|
||||
|
||||
if (!bIsSuccessful)
|
||||
{
|
||||
@ -977,9 +977,9 @@ struct TStringObjectFormatter
|
||||
Result += Begin;
|
||||
Result += Buffer;
|
||||
|
||||
auto Sentinel = Range::End(Object);
|
||||
auto Sentinel = Ranges::End(Object);
|
||||
|
||||
for (auto Iter = ++Range::Begin(Object); Iter != Sentinel; ++Iter)
|
||||
for (auto Iter = ++Ranges::Begin(Object); Iter != Sentinel; ++Iter)
|
||||
{
|
||||
Result += Separator;
|
||||
|
@ -5,16 +5,16 @@
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Templates/Optional.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Memory/Allocators.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "Containers/ArrayView.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Range/Factory.h"
|
||||
#include "String/Char.h"
|
||||
#include "String/StringView.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Ranges/Factory.h"
|
||||
#include "Strings/Char.h"
|
||||
#include "Strings/StringView.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
#include <locale>
|
||||
@ -93,7 +93,7 @@ public:
|
||||
/** Constructs the string with the contents of the range. */
|
||||
template <CInputRange R> requires (!CSameAs<TRemoveCVRef<R>, TString>
|
||||
&& !CSameAs<TRemoveCVRef<R>, TStringView<FElementType>> && CConstructibleFrom<FElementType, TRangeReference<R>>)
|
||||
FORCEINLINE explicit TString(R&& Range) : TString(Range::Begin(Range), Range::End(Range)) { }
|
||||
FORCEINLINE explicit TString(R&& Range) : TString(Ranges::Begin(Range), Ranges::End(Range)) { }
|
||||
|
||||
/** Copy constructor. Constructs the string with the copy of the contents of 'InValue'. */
|
||||
FORCEINLINE TString(const TString&) = default;
|
||||
@ -102,7 +102,7 @@ public:
|
||||
FORCEINLINE TString(TString&&) = default;
|
||||
|
||||
/** Constructs the string with the contents of the initializer list. */
|
||||
FORCEINLINE TString(initializer_list<FElementType> IL) : TString(Range::Begin(IL), Range::End(IL)) { }
|
||||
FORCEINLINE TString(initializer_list<FElementType> IL) : TString(Ranges::Begin(IL), Ranges::End(IL)) { }
|
||||
|
||||
/** Copy assignment operator. Replaces the contents with a copy of the contents of 'InValue'. */
|
||||
FORCEINLINE TString& operator=(const TString&) = default;
|
||||
@ -249,7 +249,7 @@ public:
|
||||
void StableErase(...) = delete;
|
||||
|
||||
/** Appends 'Count' copies of the 'InValue' to the end of the string. */
|
||||
TString& Append(size_t Count, FElementType InChar) { return Append(Range::Repeat(InChar, Count)); }
|
||||
TString& Append(size_t Count, FElementType InChar) { return Append(Ranges::Repeat(InChar, Count)); }
|
||||
|
||||
/** Appends the contents of the range ['InPtr', 'InPtr' + 'Count') to the end of the string. */
|
||||
FORCEINLINE TString& Append(const FElementType* InPtr, size_t Count) { return Append(TStringView<FElementType>(InPtr, Count)); }
|
||||
@ -296,10 +296,10 @@ public:
|
||||
|
||||
/** Appends the contents of the range to the end of the string. */
|
||||
template <CInputRange R> requires (CConstructibleFrom<FElementType, TRangeReference<R>>)
|
||||
FORCEINLINE TString& Append(R&& Range) { return Append(Range::Begin(Range), Range::End(Range)); }
|
||||
FORCEINLINE TString& Append(R&& Range) { return Append(Ranges::Begin(Range), Ranges::End(Range)); }
|
||||
|
||||
/** Appends the contents of the initializer list to the end of the string. */
|
||||
FORCEINLINE TString& Append(initializer_list<FElementType> IL) { return Append(Range::Begin(IL), Range::End(IL)); }
|
||||
FORCEINLINE TString& Append(initializer_list<FElementType> IL) { return Append(Ranges::Begin(IL), Ranges::End(IL)); }
|
||||
|
||||
/** Appends the given character value to the end of the string. */
|
||||
FORCEINLINE TString& operator+=(FElementType InChar) { return Append(1, InChar); }
|
||||
@ -470,7 +470,7 @@ public:
|
||||
{
|
||||
checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Replace(First, Last, Range::Repeat(InChar, Count));
|
||||
return Replace(First, Last, Ranges::Repeat(InChar, Count));
|
||||
}
|
||||
|
||||
/** Replace the substring [Index, Index + CountToReplace) with the contents of the ['InPtr', 'InPtr' + 'Count'). */
|
||||
@ -599,7 +599,7 @@ public:
|
||||
{
|
||||
checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Replace(First, Last, Range::Begin(Range), Range::End(Range));
|
||||
return Replace(First, Last, Ranges::Begin(Range), Ranges::End(Range));
|
||||
}
|
||||
|
||||
/** Replace the substring [Index, Index + CountToReplace) with the contents of the initializer list. */
|
||||
@ -615,7 +615,7 @@ public:
|
||||
{
|
||||
checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Replace(First, Last, Range::Begin(IL), Range::End(IL));
|
||||
return Replace(First, Last, Ranges::Begin(IL), Ranges::End(IL));
|
||||
}
|
||||
|
||||
/** Obtains a string that is a view over the 'Count' characters of this string view starting at 'Offset'. */
|
||||
@ -808,7 +808,7 @@ public:
|
||||
|
||||
do
|
||||
{
|
||||
const auto Result = Facet.in(State, BeginFrom, EndFrom, NextFrom, Range::Begin(Buffer), Range::End(Buffer), NextTo);
|
||||
const auto Result = Facet.in(State, BeginFrom, EndFrom, NextFrom, Ranges::Begin(Buffer), Ranges::End(Buffer), NextTo);
|
||||
|
||||
if (BeginFrom == NextFrom) return false;
|
||||
|
||||
@ -856,7 +856,7 @@ public:
|
||||
|
||||
do
|
||||
{
|
||||
const auto Result = Facet.out(State, BeginFrom, EndFrom, NextFrom, Range::Begin(Buffer), Range::End(Buffer), NextTo);
|
||||
const auto Result = Facet.out(State, BeginFrom, EndFrom, NextFrom, Ranges::Begin(Buffer), Ranges::End(Buffer), NextTo);
|
||||
|
||||
if (BeginFrom == NextFrom) return false;
|
||||
|
||||
@ -1466,4 +1466,4 @@ NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
||||
|
||||
#include "String/Conversion.h.inl"
|
||||
#include "Strings/Conversion.h.inl"
|
@ -5,13 +5,13 @@
|
||||
#include "Templates/Utility.h"
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Templates/Noncopyable.h"
|
||||
#include "Memory/Allocator.h"
|
||||
#include "Memory/Allocators.h"
|
||||
#include "Memory/MemoryOperator.h"
|
||||
#include "Containers/ArrayView.h"
|
||||
#include "Iterator/Utility.h"
|
||||
#include "Iterator/BasicIterator.h"
|
||||
#include "Iterator/Sentinel.h"
|
||||
#include "String/Char.h"
|
||||
#include "Iterators/Utility.h"
|
||||
#include "Iterators/BasicIterator.h"
|
||||
#include "Iterators/Sentinel.h"
|
||||
#include "Strings/Char.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
#include <cstring>
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Range/Utility.h"
|
||||
#include "Ranges/Utility.h"
|
||||
#include "Templates/Meta.h"
|
||||
#include "Templates/Invoke.h"
|
||||
#include "Templates/Utility.h"
|
||||
@ -479,7 +479,7 @@ struct TVariantVisitImpl
|
||||
for (size_t Index = 0; Index < sizeof...(VariantTypes); ++Index)
|
||||
{
|
||||
Result *= VariantNums[Index];
|
||||
Result += Range::Begin(Indices)[Index];
|
||||
Result += Ranges::Begin(Indices)[Index];
|
||||
}
|
||||
|
||||
return Result;
|
||||
|
@ -12,6 +12,8 @@ REDCRAFTUTILITY_API void TestTypeTraits();
|
||||
REDCRAFTUTILITY_API void TestTemplates();
|
||||
REDCRAFTUTILITY_API void TestNumeric();
|
||||
REDCRAFTUTILITY_API void TestIterator();
|
||||
REDCRAFTUTILITY_API void TestRange();
|
||||
REDCRAFTUTILITY_API void TestAlgorithms();
|
||||
REDCRAFTUTILITY_API void TestMemory();
|
||||
REDCRAFTUTILITY_API void TestContainers();
|
||||
REDCRAFTUTILITY_API void TestString();
|
||||
|
Loading…
Reference in New Issue
Block a user