refactor(templates): add FORCEINLINE to the constexpr function

This commit is contained in:
2022-12-13 22:02:39 +08:00
parent 89c173897e
commit ac9e0d38a6
14 changed files with 381 additions and 386 deletions

View File

@ -82,54 +82,56 @@ private:
public:
template <typename Type>
constexpr TTupleBasicElement(Type&& Arg)
FORCEINLINE constexpr TTupleBasicElement(Type&& Arg)
: Value(Forward<Type>(Arg))
{ }
TTupleBasicElement() = default;
TTupleBasicElement(TTupleBasicElement&&) = default;
TTupleBasicElement(const TTupleBasicElement&) = default;
TTupleBasicElement& operator=(TTupleBasicElement&&) = default;
TTupleBasicElement& operator=(const TTupleBasicElement&) = default;
FORCEINLINE constexpr TTupleBasicElement() = default;
FORCEINLINE constexpr TTupleBasicElement(const TTupleBasicElement&) = default;
FORCEINLINE constexpr TTupleBasicElement(TTupleBasicElement&&) = default;
FORCEINLINE constexpr TTupleBasicElement& operator=(const TTupleBasicElement&) = default;
FORCEINLINE constexpr TTupleBasicElement& operator=(TTupleBasicElement&&) = default;
FORCEINLINE constexpr ~TTupleBasicElement() = default;
constexpr T& GetValue() & { return static_cast< T& >(Value); }
constexpr const T& GetValue() const & { return static_cast<const T& >(Value); }
constexpr volatile T& GetValue() volatile& { return static_cast< volatile T& >(Value); }
constexpr const volatile T& GetValue() const volatile& { return static_cast<const volatile T& >(Value); }
constexpr T&& GetValue() && { return static_cast< T&&>(Value); }
constexpr const T&& GetValue() const && { return static_cast<const T&&>(Value); }
constexpr volatile T&& GetValue() volatile&& { return static_cast< volatile T&&>(Value); }
constexpr const volatile T&& GetValue() const volatile&& { return static_cast<const volatile T&&>(Value); }
FORCEINLINE constexpr T& GetValue() & { return static_cast< T& >(Value); }
FORCEINLINE constexpr const T& GetValue() const & { return static_cast<const T& >(Value); }
FORCEINLINE constexpr volatile T& GetValue() volatile& { return static_cast< volatile T& >(Value); }
FORCEINLINE constexpr const volatile T& GetValue() const volatile& { return static_cast<const volatile T& >(Value); }
FORCEINLINE constexpr T&& GetValue() && { return static_cast< T&&>(Value); }
FORCEINLINE constexpr const T&& GetValue() const && { return static_cast<const T&&>(Value); }
FORCEINLINE constexpr volatile T&& GetValue() volatile&& { return static_cast< volatile T&&>(Value); }
FORCEINLINE constexpr const volatile T&& GetValue() const volatile&& { return static_cast<const volatile T&&>(Value); }
};
#if RS_TUPLE_ELEMENT_STATIC_ALIAS
#define DEFINE_TTupleBasicElement(Index, Name) \
template <typename T> \
struct TTupleBasicElement<T, Index> \
{ \
using Name##Type = T; \
Name##Type Name; \
\
template <typename Type> \
constexpr TTupleBasicElement(Type&& Arg) \
: Name(Forward<Type>(Arg)) \
{ } \
\
TTupleBasicElement() = default; \
TTupleBasicElement(TTupleBasicElement&&) = default; \
TTupleBasicElement(const TTupleBasicElement&) = default; \
TTupleBasicElement& operator=(TTupleBasicElement&&) = default; \
TTupleBasicElement& operator=(const TTupleBasicElement&) = default; \
\
constexpr T& GetValue() & { return static_cast< T& >(Name); } \
constexpr const T& GetValue() const & { return static_cast<const T& >(Name); } \
constexpr volatile T& GetValue() volatile& { return static_cast< volatile T& >(Name); } \
constexpr const volatile T& GetValue() const volatile& { return static_cast<const volatile T& >(Name); } \
constexpr T&& GetValue() && { return static_cast< T&&>(Name); } \
constexpr const T&& GetValue() const && { return static_cast<const T&&>(Name); } \
constexpr volatile T&& GetValue() volatile&& { return static_cast< volatile T&&>(Name); } \
constexpr const volatile T&& GetValue() const volatile&& { return static_cast<const volatile T&&>(Name); } \
#define DEFINE_TTupleBasicElement(Index, Name) \
template <typename T> \
struct TTupleBasicElement<T, Index> \
{ \
using Name##Type = T; \
Name##Type Name; \
\
template <typename Type> \
FORCEINLINE constexpr TTupleBasicElement(Type&& Arg) \
: Name(Forward<Type>(Arg)) \
{ } \
\
FORCEINLINE constexpr TTupleBasicElement() = default; \
FORCEINLINE constexpr TTupleBasicElement(const TTupleBasicElement&) = default; \
FORCEINLINE constexpr TTupleBasicElement(TTupleBasicElement&&) = default; \
FORCEINLINE constexpr TTupleBasicElement& operator=(const TTupleBasicElement&) = default; \
FORCEINLINE constexpr TTupleBasicElement& operator=(TTupleBasicElement&&) = default; \
FORCEINLINE constexpr ~TTupleBasicElement() = default; \
\
FORCEINLINE constexpr T& GetValue() & { return static_cast< T& >(Name); } \
FORCEINLINE constexpr const T& GetValue() const & { return static_cast<const T& >(Name); } \
FORCEINLINE constexpr volatile T& GetValue() volatile& { return static_cast< volatile T& >(Name); } \
FORCEINLINE constexpr const volatile T& GetValue() const volatile& { return static_cast<const volatile T& >(Name); } \
FORCEINLINE constexpr T&& GetValue() && { return static_cast< T&&>(Name); } \
FORCEINLINE constexpr const T&& GetValue() const && { return static_cast<const T&&>(Name); } \
FORCEINLINE constexpr volatile T&& GetValue() volatile&& { return static_cast< volatile T&&>(Name); } \
FORCEINLINE constexpr const volatile T&& GetValue() const volatile&& { return static_cast<const volatile T&&>(Name); } \
}
DEFINE_TTupleBasicElement(0x0, First);
@ -154,7 +156,7 @@ DEFINE_TTupleBasicElement(0xF, Sixteenth);
#endif
template <typename... Ts>
constexpr TTuple<TUnwrapRefDecay<Ts>...> MakeTupleImpl(Ts&&... Args)
FORCEINLINE constexpr TTuple<TUnwrapRefDecay<Ts>...> MakeTupleImpl(Ts&&... Args)
{
return TTuple<TUnwrapRefDecay<Ts>...>(Forward<Ts>(Args)...);
}
@ -167,24 +169,23 @@ class TTupleImpl<TIndexSequence<Indices...>, Ts...> : public TTupleBasicElement<
{
protected:
TTupleImpl() = default;
FORCEINLINE constexpr TTupleImpl() = default;
FORCEINLINE constexpr TTupleImpl(const TTupleImpl&) = default;
FORCEINLINE constexpr TTupleImpl(TTupleImpl&&) = default;
FORCEINLINE constexpr TTupleImpl& operator=(const TTupleImpl&) = default;
FORCEINLINE constexpr TTupleImpl& operator=(TTupleImpl&&) = default;
FORCEINLINE constexpr ~TTupleImpl() = default;
template <typename... ArgTypes>
constexpr explicit TTupleImpl(FForwardingConstructor, ArgTypes&&... Args)
FORCEINLINE constexpr explicit TTupleImpl(FForwardingConstructor, ArgTypes&&... Args)
: TTupleBasicElement<Ts, Indices>(Forward<ArgTypes>(Args))...
{ }
template <typename TupleType>
constexpr explicit TTupleImpl(FOtherTupleConstructor, TupleType&& InValue)
FORCEINLINE constexpr explicit TTupleImpl(FOtherTupleConstructor, TupleType&& InValue)
: TTupleBasicElement<Ts, Indices>(Forward<TupleType>(InValue).template GetValue<Indices>())...
{ }
constexpr TTupleImpl(const TTupleImpl&) = default;
constexpr TTupleImpl(TTupleImpl&&) = default;
constexpr TTupleImpl& operator=(const TTupleImpl&) = default;
constexpr TTupleImpl& operator=(TTupleImpl&&) = default;
};
template <typename Indices, typename... Ts>
@ -196,7 +197,7 @@ class TTupleHelper<TIndexSequence<Indices...>>
public:
template <typename LHSTupleType, typename RHSTupleType>
static constexpr void Assign(LHSTupleType& LHS, RHSTupleType&& RHS)
FORCEINLINE static constexpr void Assign(LHSTupleType& LHS, RHSTupleType&& RHS)
{
static_assert(sizeof...(Indices) == TTupleArityImpl<TRemoveCVRef<LHSTupleType>>::Value
&& TTupleArityImpl<TRemoveCVRef<LHSTupleType>>::Value == TTupleArityImpl<TRemoveCVRef<RHSTupleType>>::Value,
@ -206,19 +207,19 @@ public:
}
template <typename F, typename TTupleType>
static constexpr auto Apply(F&& Func, TTupleType&& Arg)
FORCEINLINE static constexpr auto Apply(F&& Func, TTupleType&& Arg)
{
return Invoke(Forward<F>(Func), Forward<TTupleType>(Arg).template GetValue<Indices>()...);
}
template <typename F, typename TTupleType>
static constexpr auto Transform(F&& Func, TTupleType&& Arg)
FORCEINLINE static constexpr auto Transform(F&& Func, TTupleType&& Arg)
{
return MakeTupleImpl(Invoke(Forward<F>(Func), Forward<TTupleType>(Arg).template GetValue<Indices>())...);
}
template <typename T, typename TTupleType>
static constexpr T Construct(TTupleType&& Arg)
FORCEINLINE static constexpr T Construct(TTupleType&& Arg)
{
return T(Forward<TTupleType>(Arg).template GetValue<Indices>()...);
}
@ -249,34 +250,34 @@ private:
public:
constexpr TTuple() = default;
FORCEINLINE constexpr TTuple() = default;
template <typename... ArgTypes> requires (sizeof...(Ts) >= 1 && sizeof...(ArgTypes) == sizeof...(Ts))
&& (true && ... && CConstructibleFrom<Ts, ArgTypes&&>)
constexpr explicit (!(true && ... && CConvertibleTo<ArgTypes&&, Ts>)) TTuple(ArgTypes&&... Args)
FORCEINLINE constexpr explicit (!(true && ... && CConvertibleTo<ArgTypes&&, Ts>)) TTuple(ArgTypes&&... Args)
: Super(NAMESPACE_PRIVATE::ForwardingConstructor, Forward<ArgTypes>(Args)...)
{ }
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Ts)
&& (true && ... && CConstructibleFrom<Ts, const OtherTypes&>)
&& NAMESPACE_PRIVATE::TTupleConvertCopy<sizeof...(Ts) != 1, Ts..., OtherTypes...>::Value)
constexpr explicit (!(true && ... && CConvertibleTo<OtherTypes&&, Ts>)) TTuple(const TTuple<OtherTypes...>& InValue)
FORCEINLINE constexpr explicit (!(true && ... && CConvertibleTo<OtherTypes&&, Ts>)) TTuple(const TTuple<OtherTypes...>& InValue)
: Super(NAMESPACE_PRIVATE::OtherTupleConstructor, InValue)
{ }
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Ts)
&& (true && ... && CConstructibleFrom<Ts, OtherTypes&&>)
&& NAMESPACE_PRIVATE::TTupleConvertMove<sizeof...(Ts) != 1, Ts..., OtherTypes...>::Value)
constexpr explicit (!(true && ... && CConvertibleTo<OtherTypes&&, Ts>)) TTuple(TTuple<OtherTypes...>&& InValue)
FORCEINLINE constexpr explicit (!(true && ... && CConvertibleTo<OtherTypes&&, Ts>)) TTuple(TTuple<OtherTypes...>&& InValue)
: Super(NAMESPACE_PRIVATE::OtherTupleConstructor, MoveTemp(InValue))
{ }
constexpr TTuple(const TTuple&) = default;
constexpr TTuple(TTuple&&) = default;
FORCEINLINE constexpr TTuple(const TTuple&) = default;
FORCEINLINE constexpr TTuple(TTuple&&) = default;
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Ts)
&& (true && ... && CAssignableFrom<Ts&, const OtherTypes&>))
constexpr TTuple& operator=(const TTuple<OtherTypes...>& InValue)
FORCEINLINE constexpr TTuple& operator=(const TTuple<OtherTypes...>& InValue)
{
Helper::Assign(*this, InValue);
return *this;
@ -284,61 +285,61 @@ public:
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Ts)
&& (true && ... && CAssignableFrom<Ts&, OtherTypes&&>))
constexpr TTuple& operator=(TTuple<OtherTypes...>&& InValue)
FORCEINLINE constexpr TTuple& operator=(TTuple<OtherTypes...>&& InValue)
{
Helper::Assign(*this, MoveTemp(InValue));
return *this;
}
constexpr TTuple& operator=(const TTuple&) = default;
constexpr TTuple& operator=(TTuple&&) = default;
FORCEINLINE constexpr TTuple& operator=(const TTuple&) = default;
FORCEINLINE constexpr TTuple& operator=(TTuple&&) = default;
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() & { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const & { return static_cast<const NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const volatile& { return static_cast<const volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() && { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const && { return static_cast<const NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const volatile&& { return static_cast<const volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() & { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const & { return static_cast<const NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const volatile& { return static_cast<const volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() && { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const && { return static_cast<const NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) FORCEINLINE constexpr decltype(auto) GetValue() const volatile&& { return static_cast<const volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <typename T> constexpr decltype(auto) GetValue() & { return static_cast< TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const & { return static_cast<const TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const volatile& { return static_cast<const volatile TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() && { return static_cast< TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const && { return static_cast<const TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const volatile&& { return static_cast<const volatile TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> FORCEINLINE constexpr decltype(auto) GetValue() & { return static_cast< TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> FORCEINLINE constexpr decltype(auto) GetValue() const & { return static_cast<const TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> FORCEINLINE constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> FORCEINLINE constexpr decltype(auto) GetValue() const volatile& { return static_cast<const volatile TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> FORCEINLINE constexpr decltype(auto) GetValue() && { return static_cast< TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> FORCEINLINE constexpr decltype(auto) GetValue() const && { return static_cast<const TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> FORCEINLINE constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> FORCEINLINE constexpr decltype(auto) GetValue() const volatile&& { return static_cast<const volatile TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename F> requires (CInvocable<F, Ts...>) constexpr decltype(auto) Apply(F&& Func) & { return Helper::Apply(Forward<F>(Func), static_cast< TTuple& >(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) constexpr decltype(auto) Apply(F&& Func) const & { return Helper::Apply(Forward<F>(Func), static_cast<const TTuple& >(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) constexpr decltype(auto) Apply(F&& Func) volatile& { return Helper::Apply(Forward<F>(Func), static_cast< volatile TTuple& >(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) constexpr decltype(auto) Apply(F&& Func) const volatile& { return Helper::Apply(Forward<F>(Func), static_cast<const volatile TTuple& >(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) constexpr decltype(auto) Apply(F&& Func) && { return Helper::Apply(Forward<F>(Func), static_cast< TTuple&&>(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) constexpr decltype(auto) Apply(F&& Func) const && { return Helper::Apply(Forward<F>(Func), static_cast<const TTuple&&>(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) constexpr decltype(auto) Apply(F&& Func) volatile&& { return Helper::Apply(Forward<F>(Func), static_cast< volatile TTuple&&>(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) constexpr decltype(auto) Apply(F&& Func) const volatile&& { return Helper::Apply(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) & { return Helper::Apply(Forward<F>(Func), static_cast< TTuple& >(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const & { return Helper::Apply(Forward<F>(Func), static_cast<const TTuple& >(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) volatile& { return Helper::Apply(Forward<F>(Func), static_cast< volatile TTuple& >(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const volatile& { return Helper::Apply(Forward<F>(Func), static_cast<const volatile TTuple& >(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) && { return Helper::Apply(Forward<F>(Func), static_cast< TTuple&&>(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const && { return Helper::Apply(Forward<F>(Func), static_cast<const TTuple&&>(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) volatile&& { return Helper::Apply(Forward<F>(Func), static_cast< volatile TTuple&&>(*this)); }
template <typename F> requires (CInvocable<F, Ts...>) FORCEINLINE constexpr decltype(auto) Apply(F&& Func) const volatile&& { return Helper::Apply(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward<F>(Func), static_cast< TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward<F>(Func), static_cast<const TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward<F>(Func), static_cast< volatile TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) const volatile& { return Helper::Transform(Forward<F>(Func), static_cast<const volatile TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) && { return Helper::Transform(Forward<F>(Func), static_cast< TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) const && { return Helper::Transform(Forward<F>(Func), static_cast<const TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) volatile&& { return Helper::Transform(Forward<F>(Func), static_cast< volatile TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) const volatile&& { return Helper::Transform(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward<F>(Func), static_cast< TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward<F>(Func), static_cast<const TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward<F>(Func), static_cast< volatile TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const volatile& { return Helper::Transform(Forward<F>(Func), static_cast<const volatile TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) && { return Helper::Transform(Forward<F>(Func), static_cast< TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const && { return Helper::Transform(Forward<F>(Func), static_cast<const TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) volatile&& { return Helper::Transform(Forward<F>(Func), static_cast< volatile TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) FORCEINLINE constexpr decltype(auto) Transform(F&& Func) const volatile&& { return Helper::Transform(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) constexpr T Construct() & { return Helper::template Construct<T>(static_cast< TTuple& >(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) constexpr T Construct() const & { return Helper::template Construct<T>(static_cast<const TTuple& >(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) constexpr T Construct() volatile& { return Helper::template Construct<T>(static_cast< volatile TTuple& >(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) constexpr T Construct() const volatile& { return Helper::template Construct<T>(static_cast<const volatile TTuple& >(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) constexpr T Construct() && { return Helper::template Construct<T>(static_cast< TTuple&&>(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) constexpr T Construct() const && { return Helper::template Construct<T>(static_cast<const TTuple&&>(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) constexpr T Construct() volatile&& { return Helper::template Construct<T>(static_cast< volatile TTuple&&>(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) constexpr T Construct() const volatile&& { return Helper::template Construct<T>(static_cast<const volatile TTuple&&>(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) FORCEINLINE constexpr T Construct() & { return Helper::template Construct<T>(static_cast< TTuple& >(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) FORCEINLINE constexpr T Construct() const & { return Helper::template Construct<T>(static_cast<const TTuple& >(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) FORCEINLINE constexpr T Construct() volatile& { return Helper::template Construct<T>(static_cast< volatile TTuple& >(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) FORCEINLINE constexpr T Construct() const volatile& { return Helper::template Construct<T>(static_cast<const volatile TTuple& >(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) FORCEINLINE constexpr T Construct() && { return Helper::template Construct<T>(static_cast< TTuple&&>(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) FORCEINLINE constexpr T Construct() const && { return Helper::template Construct<T>(static_cast<const TTuple&&>(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) FORCEINLINE constexpr T Construct() volatile&& { return Helper::template Construct<T>(static_cast< volatile TTuple&&>(*this)); }
template <typename T> requires (CConstructibleFrom<T, Ts...>) FORCEINLINE constexpr T Construct() const volatile&& { return Helper::template Construct<T>(static_cast<const volatile TTuple&&>(*this)); }
constexpr size_t GetTypeHash() const requires (true && ... && CHashable<Ts>)
FORCEINLINE constexpr size_t GetTypeHash() const requires (true && ... && CHashable<Ts>)
{
return [this]<size_t... Indices>(TIndexSequence<Indices...>) -> size_t
{
@ -347,7 +348,7 @@ public:
(TMakeIndexSequence<sizeof...(Ts)>());
}
constexpr void Swap(TTuple& InValue) requires (true && ... && (CMoveConstructible<Ts>&& CSwappable<Ts>))
FORCEINLINE constexpr void Swap(TTuple& InValue) requires (true && ... && (CMoveConstructible<Ts> && CSwappable<Ts>))
{
[&A = *this, &B = InValue]<size_t... Indices>(TIndexSequence<Indices...>)
{
@ -365,19 +366,19 @@ template <typename T, typename U>
using TPair = TTuple<T, U>;
template <typename... Ts>
constexpr TTuple<TUnwrapRefDecay<Ts>...> MakeTuple(Ts&&... Args)
FORCEINLINE constexpr TTuple<TUnwrapRefDecay<Ts>...> MakeTuple(Ts&&... Args)
{
return TTuple<TUnwrapRefDecay<Ts>...>(Forward<Ts>(Args)...);
}
template <typename... Ts>
constexpr TTuple<Ts&...> Tie(Ts&... Args)
FORCEINLINE constexpr TTuple<Ts&...> Tie(Ts&... Args)
{
return TTuple<Ts&...>(Args...);
}
template <typename... Ts>
constexpr TTuple<Ts&&...> ForwardAsTuple(Ts&&... Args)
FORCEINLINE constexpr TTuple<Ts&&...> ForwardAsTuple(Ts&&... Args)
{
return TTuple<Ts&&...>(Forward<Ts>(Args)...);
}
@ -411,7 +412,7 @@ struct TTupleCatMake<TTuple<RTypes...>, TIndexSequence<Indices...>>
struct ForwardType { using Type = TConditional<CRValueReference<T>, TRemoveReference<U>&&, U>; };
template <typename TTupleType>
static constexpr TTuple<RTypes...> Do(TTupleType&& InValue)
FORCEINLINE static constexpr TTuple<RTypes...> Do(TTupleType&& InValue)
{
return TTuple<RTypes...>
(
@ -430,7 +431,7 @@ template <size_t... ForwardIndices, size_t... TTupleIndices>
struct TTupleCatForward<TIndexSequence<ForwardIndices...>, TIndexSequence<TTupleIndices...>>
{
template <typename ForwardType, typename TTupleType>
static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue)
FORCEINLINE static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue)
{
return ForwardAsTuple(Forward<ForwardType>(ForwardTuple).template GetValue<ForwardIndices>()..., Forward<TTupleType>(InValue).template GetValue<TTupleIndices>()...);
}
@ -440,7 +441,7 @@ template <typename R>
struct TTupleCatImpl
{
template <typename ForwardType, typename TTupleType, typename... OtherTTupleTypes>
static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue, OtherTTupleTypes&&... OtherValue)
FORCEINLINE static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue, OtherTTupleTypes&&... OtherValue)
{
return Do(TTupleCatForward<
TMakeIndexSequence<TTupleArity<TRemoveReference<ForwardType>>>,
@ -449,7 +450,7 @@ struct TTupleCatImpl
}
template <typename ForwardType>
static constexpr decltype(auto) Do(ForwardType&& ForwardTuple)
FORCEINLINE static constexpr decltype(auto) Do(ForwardType&& ForwardTuple)
{
return TTupleCatMake<R, TMakeIndexSequence<TTupleArity<ForwardType>>>::Do(Forward<ForwardType>(ForwardTuple));
}
@ -462,7 +463,7 @@ template <typename R, size_t I, size_t... Indices>
struct TTupleThreeWay<R, TIndexSequence<I, Indices...>>
{
template <typename LHSTupleType, typename RHSTupleType>
static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS)
FORCEINLINE static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS)
{
auto Result = SynthThreeWayCompare(LHS.template GetValue<I>(), RHS.template GetValue<I>());
if (Result != 0) return Result;
@ -474,7 +475,7 @@ template <typename R>
struct TTupleThreeWay<R, TIndexSequence<>>
{
template <typename LHSTupleType, typename RHSTupleType>
static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS)
FORCEINLINE static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS)
{
return R::equivalent;
}
@ -487,7 +488,7 @@ template <size_t I, size_t... Indices>
struct TTupleVisitImpl<TIndexSequence<I, Indices...>>
{
template <typename F, typename... TupleTypes>
static constexpr void Do(F&& Func, TupleTypes&&... Tuples)
FORCEINLINE static constexpr void Do(F&& Func, TupleTypes&&... Tuples)
{
Invoke(Forward<F>(Func), Forward<TupleTypes>(Tuples).template GetValue<I>()...);
TTupleVisitImpl<TIndexSequence<Indices...>>::Do(Forward<F>(Func), Forward<TupleTypes>(Tuples)...);
@ -498,7 +499,7 @@ template <>
struct TTupleVisitImpl<TIndexSequence<>>
{
template <typename... TupleTypes>
static constexpr void Do(TupleTypes&&... Tuples) { }
FORCEINLINE static constexpr void Do(TupleTypes&&... Tuples) { }
};
NAMESPACE_PRIVATE_END
@ -507,7 +508,7 @@ template <typename... TTupleTypes> requires (true && ... && CTTuple<TRemoveCVRef
using TTupleCatResult = typename NAMESPACE_PRIVATE::TTupleCatResultImpl<TRemoveReference<TTupleTypes>..., NAMESPACE_PRIVATE::FTupleEndFlag>::Type;;
template <typename... TTupleTypes> requires (true && ... && CTTuple<TRemoveCVRef<TTupleTypes>>)
constexpr decltype(auto) TupleCat(TTupleTypes&&... Args)
FORCEINLINE constexpr decltype(auto) TupleCat(TTupleTypes&&... Args)
{
using R = TTupleCatResult<TTupleTypes...>;
if constexpr (sizeof...(Args) == 0) return R();
@ -515,14 +516,14 @@ constexpr decltype(auto) TupleCat(TTupleTypes&&... Args)
}
template <typename... LHSTypes, typename... RHSTypes> requires (sizeof...(LHSTypes) != sizeof...(RHSTypes) || (true && ... && CWeaklyEqualityComparable<LHSTypes, RHSTypes>))
constexpr bool operator==(const TTuple<LHSTypes...>& LHS, const TTuple<RHSTypes...>& RHS)
FORCEINLINE constexpr bool operator==(const TTuple<LHSTypes...>& LHS, const TTuple<RHSTypes...>& RHS)
{
if constexpr (sizeof...(LHSTypes) != sizeof...(RHSTypes)) return false;
return [&LHS, &RHS]<size_t... Indices>(TIndexSequence<Indices...>) -> bool { return (true && ... && (LHS.template GetValue<Indices>() == RHS.template GetValue<Indices>())); } (TMakeIndexSequence<sizeof...(LHSTypes)>());
}
template <typename... LHSTypes, typename... RHSTypes> requires (sizeof...(LHSTypes) == sizeof...(RHSTypes) && (true && ... && (CSynthThreeWayComparable<LHSTypes, RHSTypes>)))
constexpr TCommonComparisonCategory<TSynthThreeWayResult<LHSTypes, RHSTypes>...> operator<=>(const TTuple<LHSTypes...>& LHS, const TTuple<RHSTypes...>& RHS)
FORCEINLINE constexpr TCommonComparisonCategory<TSynthThreeWayResult<LHSTypes, RHSTypes>...> operator<=>(const TTuple<LHSTypes...>& LHS, const TTuple<RHSTypes...>& RHS)
{
using R = TCommonComparisonCategory<TSynthThreeWayResult<LHSTypes, RHSTypes>...>;
return NAMESPACE_PRIVATE::TTupleThreeWay<R, TMakeIndexSequence<sizeof...(LHSTypes)>>::Do(LHS, RHS);
@ -530,7 +531,7 @@ constexpr TCommonComparisonCategory<TSynthThreeWayResult<LHSTypes, RHSTypes>...>
template <typename F, typename FirstTupleType, typename... TupleTypes>
requires (CTTuple<TRemoveReference<FirstTupleType>> && (true && ... && CTTuple<TRemoveReference<TupleTypes>>))
constexpr void VisitTuple(F&& Func, FirstTupleType&& FirstTuple, TupleTypes&&... Tuples)
FORCEINLINE constexpr void VisitTuple(F&& Func, FirstTupleType&& FirstTuple, TupleTypes&&... Tuples)
{
NAMESPACE_PRIVATE::TTupleVisitImpl<TMakeIndexSequence<TTupleArity<TRemoveReference<FirstTupleType>>>>
::Do(Forward<F>(Func), Forward<FirstTupleType>(FirstTuple), Forward<TupleTypes>(Tuples)...);
@ -566,14 +567,14 @@ NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility)
// Support structure binding, should not be directly used
template <size_t Index, typename ...Ts> constexpr decltype(auto) get( TTuple<Ts...>& InValue) { return static_cast< TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get(const TTuple<Ts...>& InValue) { return static_cast<const TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get( volatile TTuple<Ts...>& InValue) { return static_cast< volatile TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get(const volatile TTuple<Ts...>& InValue) { return static_cast<const volatile TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get( TTuple<Ts...>&& InValue) { return static_cast< TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get(const TTuple<Ts...>&& InValue) { return static_cast<const TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get( volatile TTuple<Ts...>&& InValue) { return static_cast< volatile TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get(const volatile TTuple<Ts...>&& InValue) { return static_cast<const volatile TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> FORCEINLINE constexpr decltype(auto) get( TTuple<Ts...>& InValue) { return static_cast< TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> FORCEINLINE constexpr decltype(auto) get(const TTuple<Ts...>& InValue) { return static_cast<const TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> FORCEINLINE constexpr decltype(auto) get( volatile TTuple<Ts...>& InValue) { return static_cast< volatile TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> FORCEINLINE constexpr decltype(auto) get(const volatile TTuple<Ts...>& InValue) { return static_cast<const volatile TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> FORCEINLINE constexpr decltype(auto) get( TTuple<Ts...>&& InValue) { return static_cast< TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> FORCEINLINE constexpr decltype(auto) get(const TTuple<Ts...>&& InValue) { return static_cast<const TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> FORCEINLINE constexpr decltype(auto) get( volatile TTuple<Ts...>&& InValue) { return static_cast< volatile TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> FORCEINLINE constexpr decltype(auto) get(const volatile TTuple<Ts...>&& InValue) { return static_cast<const volatile TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
NAMESPACE_MODULE_END(Utility)
NAMESPACE_MODULE_END(Redcraft)