ReactOS 0.4.15-dev-7834-g00c4b3d
auto_array_ptr.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Template similar to std::auto_ptr for arrays
5 * COPYRIGHT: Copyright 2009 Colin Finck (colin@reactos.org)
6 */
7
8template<typename Type>
10{
11private:
13
14public:
16
17 /* Construct an auto_array_ptr from a pointer */
18 explicit auto_array_ptr(Type* Ptr = 0) throw()
19 : m_Ptr(Ptr)
20 {
21 }
22
23 /* Construct an auto_array_ptr from an existing auto_array_ptr */
25 : m_Ptr(Right.release())
26 {
27 }
28
29 /* Destruct the auto_array_ptr and remove the corresponding array from memory */
31 {
32 delete[] m_Ptr;
33 }
34
35 /* Get the pointer address */
36 Type* get() const throw()
37 {
38 return m_Ptr;
39 }
40
41 /* Release the pointer */
42 Type* release() throw()
43 {
44 Type* Tmp = m_Ptr;
45 m_Ptr = 0;
46
47 return Tmp;
48 }
49
50 /* Reset to a new pointer */
51 void reset(Type* Ptr = 0) throw()
52 {
53 if(Ptr != m_Ptr)
54 delete[] m_Ptr;
55
56 m_Ptr = Ptr;
57 }
58
59 /* Simulate all the functionality of real arrays by casting the auto_array_ptr to Type* on demand */
60 operator Type*() const throw()
61 {
62 return m_Ptr;
63 }
64};
Type
Definition: Type.h:7
Type * release()
Type * get() const
auto_array_ptr(Type *Ptr=0)
void reset(Type *Ptr=0)
auto_array_ptr(auto_array_ptr< Type > &Right)
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898