memory/ scopedptr.bi

Summary
memory/ scopedptr.bi
LicenseCopyright © 2009, FreeBASIC Extended Library Development Group
ext
ScopedPtrThis class implements a pointer container similiar to boost::scoped_ptr.
Functions
constuctorThis constructor takes another ScopedPtr as its argument and transfers ownership to the newly created ScopedPtr.
constructorThis constructor takes a pointer of (type) and becomes responsible for its deletion.
constructorThis constructor takes a pointer of (type) and will call a user passed subroutine to free the memory.
destructor
Operator LetTransfers ownership of a pointer to the lhs ScopedPtr.
Operator CastProvided to allow passing a ScopedPtr(type) to a procedure requiring a (type) ptr
GetProvided to allow passing a ScopedPtr(type) to a procedure requiring a (type) ptr
* (dereference)Dereferences the (type) pointer owned by a ScopedPtr returning the value pointed to by the pointer.

License

Copyright © 2009, FreeBASIC Extended Library Development Group

Distributed under the FreeBASIC Extended Library Group license.  See accompanying file LICENSE.txt or copy at http://code.google.com- /p- /fb-extended-lib- /wiki- /License

ext

ScopedPtr

This class implements a pointer container similiar to boost::scoped_ptr.

Description

A ScopedPtr is guaranteed to be deleted when it goes out of scope.

A ScopedPtr has sole ownership of a pointer, if assigned to another ScopedPtr the new ScopedPtr will gain ownership of the pointer and the original ScopedPtr is now invalid.

Summary
Functions
constuctorThis constructor takes another ScopedPtr as its argument and transfers ownership to the newly created ScopedPtr.
constructorThis constructor takes a pointer of (type) and becomes responsible for its deletion.
constructorThis constructor takes a pointer of (type) and will call a user passed subroutine to free the memory.
destructor
Operator LetTransfers ownership of a pointer to the lhs ScopedPtr.
Operator CastProvided to allow passing a ScopedPtr(type) to a procedure requiring a (type) ptr
GetProvided to allow passing a ScopedPtr(type) to a procedure requiring a (type) ptr
* (dereference)Dereferences the (type) pointer owned by a ScopedPtr returning the value pointed to by the pointer.

Functions

constuctor

This constructor takes another ScopedPtr as its argument and transfers ownership to the newly created ScopedPtr.

constructor

declare constructor (byval p as fbext_TypeName(T_) ptr =  null)

This constructor takes a pointer of (type) and becomes responsible for its deletion.

Description

When constructing a ScopedPtr with this constructor delete will be used to free the memory.

constructor

declare constructor (byval p as fbext_TypeName(T_) ptr,
byval destroy as fbext_DestroyProc(T_))

This constructor takes a pointer of (type) and will call a user passed subroutine to free the memory.

destructor

declare destructor ( )

Operator Let

Transfers ownership of a pointer to the lhs ScopedPtr.

Usage

var myptr = type<ScopedPtrinteger>(new integer)
var mysecondptr = myptr

mysecondptr now has control of the pointer and myptr is invalid.

Operator Cast

Provided to allow passing a ScopedPtr(type) to a procedure requiring a (type) ptr

Get

declare function Get () as fbext_TypeName(T_) ptr

Provided to allow passing a ScopedPtr(type) to a procedure requiring a (type) ptr

* (dereference)

declare operator * (byref rhs as fbext_ScopedPtr(T_)) as fbext_TypeName(T_)

Dereferences the (type) pointer owned by a ScopedPtr returning the value pointed to by the pointer.

declare constructor (byval p as fbext_TypeName(T_) ptr =  null)
This constructor takes a pointer of (type) and becomes responsible for its deletion.
declare destructor ( )
declare function Get () as fbext_TypeName(T_) ptr
Provided to allow passing a ScopedPtr(type) to a procedure requiring a (type) ptr
declare operator * (byref rhs as fbext_ScopedPtr(T_)) as fbext_TypeName(T_)
Dereferences the (type) pointer owned by a ScopedPtr returning the value pointed to by the pointer.