diff options
| author | Stefan Boberg <[email protected]> | 2022-01-25 15:16:04 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2022-01-25 15:16:04 +0100 |
| commit | 080b73be664064d13eb88e53cd627ef859aa7da8 (patch) | |
| tree | 1614a7637a33551e46dcb53ebb0e92d02a26b4f7 /zencore | |
| parent | Implemented support for storing compressed buffers as values in structured ca... (diff) | |
| parent | Cachepolicy (#36) (diff) | |
| download | zen-080b73be664064d13eb88e53cd627ef859aa7da8.tar.xz zen-080b73be664064d13eb88e53cd627ef859aa7da8.zip | |
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zencore')
| -rw-r--r-- | zencore/include/zencore/refcount.h | 17 | ||||
| -rw-r--r-- | zencore/include/zencore/string.h | 22 |
2 files changed, 39 insertions, 0 deletions
diff --git a/zencore/include/zencore/refcount.h b/zencore/include/zencore/refcount.h index 0324b94cc..afee8536f 100644 --- a/zencore/include/zencore/refcount.h +++ b/zencore/include/zencore/refcount.h @@ -94,10 +94,27 @@ public: } return *this; } + template<typename OtherType> + inline RefPtr& operator=(RefPtr<OtherType>&& Rhs) noexcept + { + if ((RefPtr*)&Rhs != this) + { + m_Ref && m_Ref->Release(); + m_Ref = Rhs.m_Ref; + Rhs.m_Ref = nullptr; + } + return *this; + } inline RefPtr(RefPtr&& Rhs) noexcept : m_Ref(Rhs.m_Ref) { Rhs.m_Ref = nullptr; } + template<typename OtherType> + explicit inline RefPtr(RefPtr<OtherType>&& Rhs) noexcept : m_Ref(Rhs.m_Ref) + { + Rhs.m_Ref = nullptr; + } private: T* m_Ref = nullptr; + friend class RefPtr; }; /** diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h index 1e8907906..4c378730f 100644 --- a/zencore/include/zencore/string.h +++ b/zencore/include/zencore/string.h @@ -413,6 +413,17 @@ private: char m_StringBuffer[N]; }; +template<size_t N> +class WriteToString : public ExtendableStringBuilder<N> +{ +public: + template<typename... ArgTypes> + explicit WriteToString(ArgTypes&&... Args) + { + (*this << ... << std::forward<ArgTypes>(Args)); + } +}; + ////////////////////////////////////////////////////////////////////////// extern template class StringBuilderImpl<wchar_t>; @@ -454,6 +465,17 @@ private: wchar_t m_Buffer[N]; }; +template<size_t N> +class WriteToWideString : public ExtendableWideStringBuilder<N> +{ +public: + template<typename... ArgTypes> + explicit WriteToWideString(ArgTypes&&... Args) + { + (*this << ... << Forward<ArgTypes>(Args)); + } +}; + ////////////////////////////////////////////////////////////////////////// void Utf8ToWide(const char8_t* str, WideStringBuilderBase& out); |