The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
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

Public Member Functions

 scoped_ptr (T *p)
 
- Public Member Functions inherited from util::scoped_resource< T *, delete_item >
 scoped_resource (resource_type res=resource_type())
 Constructor. More...
 
virtual ~scoped_resource ()
 The destructor is the main point in this class. More...
 
 operator resource_type () const
 This operator makes sure you can access and use the scoped_resource just like you were using the resource itself. More...
 
resource_type get () const
 This function provides explicit access to the resource. More...
 
resource_type operator-> () const
 This function provides convenient direct access to the -> operator if the underlying resource is a pointer. More...
 
void assign (const resource_type &o)
 

Additional Inherited Members

- Public Types inherited from util::scoped_resource< T *, delete_item >
typedef T * resource_type
 
typedef delete_item release_type
 

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 158 of file scoped_resource.hpp.

Constructor & Destructor Documentation

template<typename T>
util::scoped_ptr< T >::scoped_ptr ( T *  p)
inlineexplicit

Definition at line 160 of file scoped_resource.hpp.


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