A simple smart pointer providing strict ownership semantics.
#include <auto_ptr.h>
AutoPtr (element_type *p=0)
An AutoPtr is usually constructed from a raw pointer.
AutoPtr (AutoPtr &a)
An AutoPtr can be constructed from another AutoPtr.
template<typename Tp1 > AutoPtr (AutoPtr< Tp1 > &a)
An AutoPtr can be constructed from another AutoPtr.
AutoPtr & operator= (AutoPtr &a)
AutoPtr assignment operator.
template<typename Tp1 > AutoPtr & operator= (AutoPtr< Tp1 > &a)
AutoPtr assignment operator.
~AutoPtr ()
element_type & operator* () const
Smart pointer dereferencing.
element_type * operator-> () const
Smart pointer dereferencing.
element_type * get () const
Bypassing the smart pointer.
element_type * release ()
Bypassing the smart pointer.
void reset (element_type *p=0)
Forcibly deletes the managed object.
AutoPtr (AutoPtrRef< element_type > ref)
Automatic conversions.
AutoPtr & operator= (AutoPtrRef< element_type > ref)
template<typename Tp1 > operator AutoPtrRef< Tp1 > ()
template<typename Tp1 > operator AutoPtr< Tp1 > ()
The Standard says:
An AutoPtr owns the object it holds a pointer to. Copying an AutoPtr copies the pointer and transfers ownership to the destination. If more than one AutoPtr owns the same object at the same time the behavior of the program is undefined.
The uses of AutoPtr include providing temporary exception-safety for dynamically allocated memory, passing ownership of dynamically allocated memory to a function, and returning dynamically allocated memory from a function. AutoPtr does not meet the CopyConstructible and Assignable requirements for Standard Library container elements and thus instantiating a Standard Library container with an AutoPtr results in undefined behavior.
Quoted from [20.4.5]/3.
This class is adopted from the GCC 3.2.1 source tree and should function as a replacement for std::auto_ptr<>. Unfortunately the std::auto_ptr<> is not particularly portable since various compilers implement various revisions of the standard. Using AutoPtr<> instead of std::auto_ptr<> allows for easy portability.
Definition at line 103 of file auto_ptr.h.
Definition at line 116 of file auto_ptr.h.
An AutoPtr is usually constructed from a raw pointer. Parameters:
This object now owns the object pointed to by p.
Definition at line 125 of file auto_ptr.h.
: _ptr(p) {}
An AutoPtr can be constructed from another AutoPtr. Parameters:
This object now owns the object previously owned by a, which has given up ownsership.
Definition at line 135 of file auto_ptr.h.
: _ptr(a.release()) {}
An AutoPtr can be constructed from another AutoPtr. Parameters:
A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type.
This object now owns the object previously owned by a, which has given up ownsership.
Definition at line 148 of file auto_ptr.h.
: _ptr(a.release()) {}
maint
Definition at line 196 of file auto_ptr.h.
{ delete _ptr; }
Automatic conversions. These operations convert an AutoPtr into and from an AutoPtrRef automatically as needed. This allows constructs such as
AutoPtr<Derived> func_returning_AutoPtr(.....);
...
AutoPtr<Base> ptr = func_returning_AutoPtr(.....);
Definition at line 278 of file auto_ptr.h.
: _ptr(ref._ptr) {}
Bypassing the smart pointer. Returns:
You can get a copy of the pointer that this object owns, for situations such as passing to a function which only accepts a raw pointer.
Note:
Definition at line 229 of file auto_ptr.h.
Referenced by __libmesh_petsc_diff_solver_jacobian(), __libmesh_petsc_diff_solver_residual(), ExactSolution::_compute_error(), UniformRefinementEstimator::_estimate_error(), NonlinearImplicitSystem::adjoint_solve(), FEMSystem::assembly(), System::calculate_norm(), Xdr::close(), Xdr::comment(), System::compare(), Problem_Interface::computeF(), ContinuationSystem::continuation_solve(), Xdr::data(), Xdr::data_stream(), AdaptiveTimeSolver::element_residual(), DofMap::enforce_constraints_exactly(), AdaptiveTimeSolver::error_order(), PatchRecoveryErrorEstimator::estimate_error(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), FEMSystem::eulerian_residual(), TimeSolver::init(), AdaptiveTimeSolver::init(), DifferentiableSystem::init_data(), InfFE< Dim, T_radial, T_map >::inverse_map(), Xdr::is_open(), InfFE< Dim, T_radial, T_map >::map(), DofMap::max_constraint_error(), Xdr::open(), PostscriptIO::plot_quadratic_elem(), MeshBase::point_locator(), System::project_vector(), AdaptiveTimeSolver::reinit(), HPCoarsenTest::select_refinement(), AdaptiveTimeSolver::side_residual(), TwostepTimeSolver::solve(), PetscDiffSolver::solve(), and ContinuationSystem::solve_tangent().
{ return _ptr; }
Definition at line 309 of file auto_ptr.h.
{ return AutoPtr<Tp1>(this->release()); }
Definition at line 302 of file auto_ptr.h.
{ return AutoPtrRef<Tp1>(this->release()); }
Smart pointer dereferencing. If this AutoPtr no longer owns anything, then this operation will crash. (For a smart pointer, 'no longer owns anything' is the same as being a null pointer, and you know what happens when you dereference one of those...)
Definition at line 207 of file auto_ptr.h.
{ return *_ptr; }
Smart pointer dereferencing. This returns the pointer itself, which the language then will automatically cause to be dereferenced.
Definition at line 216 of file auto_ptr.h.
{ return _ptr; }
AutoPtr assignment operator. Parameters:
A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type.
This object now owns the object previously owned by a, which has given up ownsership. The object that this one used to own and track has been deleted.
Definition at line 178 of file auto_ptr.h.
{
reset(a.release());
return *this;
}
AutoPtr<Base> ptr = func_returning_AutoPtr(.....);
Definition at line 288 of file auto_ptr.h.
{
if (ref._ptr != this->get())
{
delete _ptr;
_ptr = ref._ptr;
}
return *this;
}
AutoPtr assignment operator. Parameters:
This object now owns the object previously owned by a, which has given up ownsership. The object that this one used to own and track has been deleted.
Definition at line 160 of file auto_ptr.h.
{
reset(a.release());
return *this;
}
Bypassing the smart pointer. Returns:
You can get a copy of the pointer that this object owns, for situations such as passing to a function which only accepts a raw pointer.
Note:
Definition at line 243 of file auto_ptr.h.
Referenced by UniformRefinementEstimator::_estimate_error(), InfFE< Dim, T_radial, T_map >::attach_quadrature_rule(), InfFE< Dim, T_radial, T_map >::Base::build_elem(), FEMContext::FEMContext(), InfFE< Dim, T_radial, T_map >::InfFE(), InfFE< Dim, T_radial, T_map >::init_face_shape_functions(), AutoPtr< LinearSolver< Number > >::operator AutoPtr< Tp1 >(), AutoPtr< LinearSolver< Number > >::operator AutoPtrRef< Tp1 >(), AutoPtr< LinearSolver< Number > >::operator=(), MeshBase::point_locator(), InfFE< Dim, T_radial, T_map >::reinit(), and AdaptiveTimeSolver::~AdaptiveTimeSolver().
{
element_type* tmp = _ptr;
_ptr = 0;
return tmp;
}
Forcibly deletes the managed object. Parameters:
This object now owns the object pointed to by p. The previous object has been deleted.
Definition at line 258 of file auto_ptr.h.
Referenced by UniformRefinementEstimator::_estimate_error(), AdaptiveTimeSolver::AdaptiveTimeSolver(), NonlinearSolver< T >::build(), MeshBase::clear_point_locator(), Xdr::close(), Xdr::open(), AutoPtr< LinearSolver< Number > >::operator=(), MeshBase::point_locator(), BoundaryInfo::sync(), and TwostepTimeSolver::TwostepTimeSolver().
{
if (p != _ptr)
{
delete _ptr;
_ptr = p;
}
}
Definition at line 110 of file auto_ptr.h.
Referenced by AutoPtr< LinearSolver< Number > >::get(), AutoPtr< LinearSolver< Number > >::operator*(), AutoPtr< LinearSolver< Number > >::operator->(), AutoPtr< LinearSolver< Number > >::operator=(), AutoPtr< LinearSolver< Number > >::release(), AutoPtr< LinearSolver< Number > >::reset(), and AutoPtr< LinearSolver< Number > >::~AutoPtr().
Generated automatically by Doxygen for libMesh from the source code.