util::scoped_ptr< T > Struct Template Reference

A class which implements an approximation of template<typename T> typedef scoped_resource<T*,delete_item> scoped_ptr<T>;. More...

#include <scoped_resource.hpp>

Inheritance diagram for util::scoped_ptr< T >:

Inheritance graph
[legend]
Collaboration diagram for util::scoped_ptr< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 scoped_ptr (T *p)


Detailed Description

template<typename T>
struct util::scoped_ptr< T >

A class which implements an approximation of template<typename T> typedef scoped_resource<T*,delete_item> scoped_ptr<T>;.

It is a convenient synonym for a common usage of scoped_resource. See scoped_resource for more details on how this class behaves.

Usage example:

 {
    const scoped_ptr<Object> ptr(new Object);
    ...use ptr as you would a normal Object*...
 } // ptr is automatically deleted here

NOTE: use this class only to manage a single object, *never* an array. Use scoped_array to manage arrays. This distinction is because you may call delete only on objects allocated with new, delete[] only on objects allocated with new[].

Definition at line 156 of file scoped_resource.hpp.


Constructor & Destructor Documentation

template<typename T>
util::scoped_ptr< T >::scoped_ptr ( T *  p  )  [inline, explicit]

Definition at line 158 of file scoped_resource.hpp.


The documentation for this struct was generated from the following file:

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs