feat(range): add simple view concept and refactor related requires
This commit is contained in:
parent
dd3a366c14
commit
e6d525f2c3
@ -34,9 +34,17 @@ public:
|
|||||||
|
|
||||||
FORCEINLINE constexpr explicit TMoveView(V InBase) : Base(MoveTemp(InBase)) { }
|
FORCEINLINE constexpr explicit TMoveView(V InBase) : Base(MoveTemp(InBase)) { }
|
||||||
|
|
||||||
NODISCARD FORCEINLINE constexpr auto Begin() { return MakeMoveIterator(Range::Begin(Base)); }
|
NODISCARD FORCEINLINE constexpr auto Begin() requires (!CSimpleView<V>)
|
||||||
|
{
|
||||||
|
return MakeMoveIterator(Range::Begin(Base));
|
||||||
|
}
|
||||||
|
|
||||||
NODISCARD FORCEINLINE constexpr auto End()
|
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const V>)
|
||||||
|
{
|
||||||
|
return MakeMoveIterator(Range::Begin(Base));
|
||||||
|
}
|
||||||
|
|
||||||
|
NODISCARD FORCEINLINE constexpr auto End() requires (!CSimpleView<V>)
|
||||||
{
|
{
|
||||||
if constexpr (CCommonRange<V>)
|
if constexpr (CCommonRange<V>)
|
||||||
{
|
{
|
||||||
@ -45,9 +53,7 @@ public:
|
|||||||
else return MakeMoveSentinel(Range::End(Base));
|
else return MakeMoveSentinel(Range::End(Base));
|
||||||
}
|
}
|
||||||
|
|
||||||
NODISCARD FORCEINLINE constexpr auto Begin() const requires (CRange<const V>) { return MakeMoveIterator(Range::Begin(Base)); }
|
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const V>)
|
||||||
|
|
||||||
NODISCARD FORCEINLINE constexpr auto End() const requires (CRange<const V>)
|
|
||||||
{
|
{
|
||||||
if constexpr (CCommonRange<V>)
|
if constexpr (CCommonRange<V>)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
FORCEINLINE constexpr TTakeView(V InBase, size_t InCount) : Base(MoveTemp(InBase)), Count(InCount) { }
|
FORCEINLINE constexpr TTakeView(V InBase, size_t InCount) : Base(MoveTemp(InBase)), Count(InCount) { }
|
||||||
|
|
||||||
NODISCARD FORCEINLINE constexpr auto Begin()
|
NODISCARD FORCEINLINE constexpr auto Begin() requires (!CSimpleView<V>)
|
||||||
{
|
{
|
||||||
if constexpr (CSizedRange<V>)
|
if constexpr (CSizedRange<V>)
|
||||||
{
|
{
|
||||||
@ -62,7 +62,7 @@ public:
|
|||||||
else return MakeCountedIterator(Range::Begin(Base), Count);
|
else return MakeCountedIterator(Range::Begin(Base), Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
NODISCARD FORCEINLINE constexpr auto End()
|
NODISCARD FORCEINLINE constexpr auto End() requires (!CSimpleView<V>)
|
||||||
{
|
{
|
||||||
if constexpr (CSizedRange<V>)
|
if constexpr (CSizedRange<V>)
|
||||||
{
|
{
|
||||||
|
@ -98,6 +98,12 @@ concept CViewableRange = CRange<R>
|
|||||||
|| (!CView<TRemoveCVRef<R>> && (CLValueReference<R> || (CMovable<TRemoveReference<R>>
|
|| (!CView<TRemoveCVRef<R>> && (CLValueReference<R> || (CMovable<TRemoveReference<R>>
|
||||||
&& !NAMESPACE_PRIVATE::TIsInitializerList<TRemoveCVRef<R>>::Value))));
|
&& !NAMESPACE_PRIVATE::TIsInitializerList<TRemoveCVRef<R>>::Value))));
|
||||||
|
|
||||||
|
/** A concept specifies that a view uses the same iterator and sentinel type for both const and non-const views. */
|
||||||
|
template <typename V>
|
||||||
|
concept CSimpleView = CView<V> && CRange<const V>
|
||||||
|
&& CSameAs<TRangeIterator<V>, TRangeIterator<const V>>
|
||||||
|
&& CSameAs<TRangeSentinel<V>, TRangeSentinel<const V>>;
|
||||||
|
|
||||||
NAMESPACE_BEGIN(Range)
|
NAMESPACE_BEGIN(Range)
|
||||||
|
|
||||||
/** A simple view that combines an iterator-sentinel pair into a view. */
|
/** A simple view that combines an iterator-sentinel pair into a view. */
|
||||||
|
Loading…
Reference in New Issue
Block a user