|
@@ -14,7 +14,7 @@ class scoped_array
|
|
{
|
|
{
|
|
public:
|
|
public:
|
|
|
|
|
|
- // provide a default construtctor
|
|
|
|
|
|
+ // provide a default construtctor
|
|
scoped_array()
|
|
scoped_array()
|
|
: ptr(0)
|
|
: ptr(0)
|
|
{
|
|
{
|
|
@@ -25,25 +25,25 @@ public:
|
|
: ptr(_ptr)
|
|
: ptr(_ptr)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
-
|
|
|
|
- // automatic destruction of the wrapped object at the
|
|
|
|
|
|
+
|
|
|
|
+ // automatic destruction of the wrapped object at the
|
|
// end of our lifetime
|
|
// end of our lifetime
|
|
~scoped_array()
|
|
~scoped_array()
|
|
{
|
|
{
|
|
delete[] ptr;
|
|
delete[] ptr;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
inline T* get()
|
|
inline T* get()
|
|
{
|
|
{
|
|
return ptr;
|
|
return ptr;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
inline operator T*()
|
|
inline operator T*()
|
|
{
|
|
{
|
|
return ptr;
|
|
return ptr;
|
|
}
|
|
}
|
|
-
|
|
|
|
- inline T* operator-> ()
|
|
|
|
|
|
+
|
|
|
|
+ inline T* operator-> ()
|
|
{
|
|
{
|
|
return ptr;
|
|
return ptr;
|
|
}
|
|
}
|
|
@@ -63,15 +63,15 @@ public:
|
|
{
|
|
{
|
|
std::swap(ptr, b.ptr);
|
|
std::swap(ptr, b.ptr);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
private:
|
|
private:
|
|
-
|
|
|
|
|
|
+
|
|
// encapsulated object pointer
|
|
// encapsulated object pointer
|
|
T* ptr;
|
|
T* ptr;
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
-template<class T>
|
|
|
|
|
|
+template<class T>
|
|
inline void swap(scoped_array<T> & a, scoped_array<T> & b)
|
|
inline void swap(scoped_array<T> & a, scoped_array<T> & b)
|
|
{
|
|
{
|
|
a.swap(b);
|
|
a.swap(b);
|
|
@@ -82,4 +82,5 @@ inline void swap(scoped_array<T> & a, scoped_array<T> & b)
|
|
#else
|
|
#else
|
|
# error "scoped_array.h was already included"
|
|
# error "scoped_array.h was already included"
|
|
#endif
|
|
#endif
|
|
-#endif // __AI_BOOST_SCOPED_ARRAY_INCLUDED
|
|
|
|
|
|
+#endif // __AI_BOOST_SCOPED_ARRAY_INCLUDED
|
|
|
|
+
|