diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index 58c2f937..65c24ff9 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -855,160 +855,6 @@ namespace winstd T* m_data; ///< memory pointer }; - /// - /// Helper class for returning pointers to std::unique_ptr - /// - template - class ref_unique_ptr - { - public: - /// - /// Takes ownership of the pointer - /// - /// \param[inout] owner Object to attach helper to - /// - ref_unique_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner) : - m_own(owner), - m_ptr(owner.release()) - {} - - /// - /// Moves object - /// - /// \param[inout] other Source object - /// - ref_unique_ptr(_Inout_ ref_unique_ptr<_Ty, _Dx> &&other) : - m_own(other.m_own), - m_ptr(other.m_ptr) - { - other.m_ptr = nullptr; - } - - /// - /// Returns ownership of the pointer - /// - ~ref_unique_ptr() - { - if (m_ptr != nullptr) - m_own.reset(m_ptr); - } - - /// - /// Operator for pointer-to-pointer parameters by value use-cases. - /// - /// \return Pointer to the pointer - /// - operator typename _Ty**() - { - return &m_ptr; - } - - /// - /// Operator for reverence-to-pointer parameters by value use-cases. - /// - /// \return Reference to the pointer - /// - operator typename _Ty*&() - { - return m_ptr; - } - - protected: - std::unique_ptr<_Ty, _Dx> &m_own; ///< Original owner of the pointer - _Ty *m_ptr; ///< Pointer - }; - - /// - /// Helper function template for returning pointers to std::unique_ptr - /// - /// \param[inout] owner Original owner of the pointer - /// - /// \returns A helper wrapper class to handle returning a reference to the pointer - /// - template - ref_unique_ptr<_Ty, _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner) noexcept - { - return ref_unique_ptr<_Ty, _Dx>(owner); - } - - /// - /// Helper class for returning pointers to std::unique_ptr - /// (specialization for arrays) - /// - template - class ref_unique_ptr<_Ty[], _Dx> - { - public: - /// - /// Takes ownership of the pointer - /// - /// \param[inout] owner Object to attach helper to - /// - ref_unique_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner) noexcept : - m_own(owner), - m_ptr(owner.release()) - {} - - /// - /// Moves object - /// - /// \param[inout] other Source object - /// - ref_unique_ptr(_Inout_ ref_unique_ptr<_Ty[], _Dx> &&other) : - m_own(other.m_own), - m_ptr(other.m_ptr) - { - other.m_ptr = nullptr; - } - - /// - /// Returns ownership of the pointer - /// - virtual ~ref_unique_ptr() - { - if (m_ptr != nullptr) - m_own.reset(m_ptr); - } - - /// - /// Operator for pointer-to-pointer parameters by value use-cases. - /// - /// \return Pointer to the pointer - /// - operator typename _Ty**() noexcept - { - return &m_ptr; - } - - /// - /// Operator for reverence-to-pointer parameters by value use-cases. - /// - /// \return Reference to the pointer - /// - operator typename _Ty*&() - { - return m_ptr; - } - - protected: - std::unique_ptr<_Ty[], _Dx> &m_own; ///< Original owner of the pointer - _Ty *m_ptr; ///< Pointer - }; - - /// - /// Helper function template for returning pointers to std::unique_ptr - /// (specialization for arrays) - /// - /// \param[inout] owner Original owner of the pointer - /// - /// \returns A helper wrapper class to handle returning a reference to the pointer - /// - template - ref_unique_ptr<_Ty[], _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx>& owner) noexcept - { - return ref_unique_ptr<_Ty[], _Dx>(owner); - } - /// @} /// \addtogroup WinStdSysHandles