.. index:: pair: class; EE::System::TScopedBuffer .. _doxid-class_e_e_1_1_system_1_1_t_scoped_buffer: template class EE::System::TScopedBuffer ======================================== .. toctree:: :hidden: Overview ~~~~~~~~ Keep a pointer to a buffer and release it when the ScopedBuffer goes out of scope. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class TScopedBuffer: private :ref:`EE::NonCopyable` { public: // construction :target:`TScopedBuffer`(); :target:`TScopedBuffer`(std::size_t length); :target:`TScopedBuffer`(T* data, std::size_t length); :ref:`~TScopedBuffer`(); // methods void :target:`clear`(); T& :target:`operator[]`(std::size_t i) const; bool :target:`operator()`() const; T* :target:`get`() const; void :target:`swap`(TScopedBuffer& b); void :target:`reset`(T* p = 0, const std::size_t& size = 0); void :target:`reset`(const std::size_t& size = 0); void :ref:`reset`(const T* p = 0, const std::size_t& size = 0); bool :target:`isEmpty`() const; const std::size_t& :target:`size`() const; const std::size_t& :target:`length`() const; }; .. _details-class_e_e_1_1_system_1_1_t_scoped_buffer: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Keep a pointer to a buffer and release it when the ScopedBuffer goes out of scope. The :ref:`TScopedBuffer ` class template stores a pointer to a dynamically allocated array. (Dynamically allocated arrays are allocated with the C++ new[] expression.) The array pointed to is guaranteed to be deleted, either on destruction of the :ref:`TScopedBuffer `, or via an explicit reset. The :ref:`TScopedBuffer ` template is a simple solution for simple needs. It supplies a basic "resource acquisition is initialization" facility, without shared-ownership or transfer-of-ownership semantics. Both its name and enforcement of semantics (by being :ref:`NonCopyable `) signal its intent to retain ownership solely within the current scope. Construction ------------ .. _doxid-class_e_e_1_1_system_1_1_t_scoped_buffer_1ac9522d5663a7433fde467ff8da98de08: .. ref-code-block:: cpp :class: doxyrest-title-code-block ~TScopedBuffer() The destructor deletes the buffer. Methods ------- .. index:: pair: function; reset .. _doxid-class_e_e_1_1_system_1_1_t_scoped_buffer_1a30faf2486c89746ee6d92eaca1966ed6: .. ref-code-block:: cpp :class: doxyrest-title-code-block void reset(const T* p = 0, const std::size_t& size = 0) creates a copy of p