SyDEVS  v0.6.5
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sydevs::pointer Class Reference

A data type which represents a pointer to anything. More...

#include <pointer.h>

Public Member Functions

 pointer () noexcept
 Constructs a null pointer instance. More...
 
 pointer (std::nullptr_t X) noexcept
 Constructs a null pointer instance from a nullptr. More...
 
template<typename T >
 pointer (T *ptr)
 Constructs a pointer instance referencing the same data as ptr. More...
 
 pointer (const pointer &) noexcept=default
 Copy constructor. More...
 
pointeroperator= (const pointer &) noexcept=default
 Copy assignment. More...
 
 pointer (pointer &&) noexcept=default
 Move constructor. More...
 
pointeroperator= (pointer &&) noexcept=default
 Move assignment. More...
 
 ~pointer ()=default
 Destructor. More...
 
void reset () noexcept
 Modifies the pointer to reference nullptr. More...
 
template<typename T >
void reset (T *ptr)
 Modifies the pointer to reference the same data as ptr. More...
 
template<typename T >
T & dereference () const
 Returns the referenced data, casting it to type T. More...
 
 operator bool () const noexcept
 Returns true if the pointer does not reference nullptr. More...
 

Detailed Description

A data type which represents a pointer to anything.

A pointer instance encapsulates std::shared_ptr<void>, which is essentially a reference-counted pointer to any type of data. The example below demonstrates how to use the class.

auto val = pointer(new int64(7));
val.reset();
val.reset(new float64(-0.5));
if (val) {
auto x = val.dereference<float64>();
}

Constructor & Destructor Documentation

sydevs::pointer::pointer ( )
inlinenoexcept

Constructs a null pointer instance.

sydevs::pointer::pointer ( std::nullptr_t  X)
inlineexplicitnoexcept

Constructs a null pointer instance from a nullptr.

template<typename T >
sydevs::pointer::pointer ( T *  ptr)
inlineexplicit

Constructs a pointer instance referencing the same data as ptr.

sydevs::pointer::pointer ( const pointer )
defaultnoexcept

Copy constructor.

sydevs::pointer::pointer ( pointer &&  )
defaultnoexcept

Move constructor.

sydevs::pointer::~pointer ( )
default

Destructor.

Member Function Documentation

template<typename T >
T & sydevs::pointer::dereference ( ) const
inline

Returns the referenced data, casting it to type T.

sydevs::pointer::operator bool ( ) const
inlineexplicitnoexcept

Returns true if the pointer does not reference nullptr.

pointer& sydevs::pointer::operator= ( const pointer )
defaultnoexcept

Copy assignment.

pointer& sydevs::pointer::operator= ( pointer &&  )
defaultnoexcept

Move assignment.

void sydevs::pointer::reset ( )
inlinenoexcept

Modifies the pointer to reference nullptr.

template<typename T >
void sydevs::pointer::reset ( T *  ptr)
inline

Modifies the pointer to reference the same data as ptr.


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