WARPXM v1.10.0
Loading...
Searching...
No Matches
WxAny Class Reference

Class WxAny is based on the "any" class described in "Valued Conversion", Kevlin Henney, C++ Report, July-August 2000, pages 37–40. More...

#include <wxany.h>

Detailed Description

Class WxAny is based on the "any" class described in "Valued Conversion", Kevlin Henney, C++ Report, July-August 2000, pages 37–40.

WxAny should be used for objects with simple types which support a copy ctor.

Example usage is:

WxAny any(22); // store integer 22 cout << any.to_value<int>() << endl; // prints 22

any = WxAny(string("Hello World") ); // store string cout << any.to_value<string>() << endl; // prints "Hello World"

Public Member Functions

 WxAny ()
 Create empty object.
 
template<typename VALUETYPE >
 WxAny (const VALUETYPE &value)
 Create new WxAny from an object of a given type.
 
 WxAny (const WxAny &other)
 Copy ctor.
 
 WxAny (WxAny &&other) noexcept
 move ctor
 
 ~WxAny ()
 
WxAnyswap (WxAny &rhs)
 Swap contents of object with contents of supplied object.
 
WxAnyoperator= (const WxAny &rhs)
 Assignment operator: use WxAny object to create a new object.
 
WxAnyoperator= (WxAny &&rhs) noexcept
 
template<typename VALUETYPE >
WxAnyoperator= (const VALUETYPE &rhs)
 Assignment operator: use VALUETYPE object to create a new object.
 
bool empty () const
 Is object empty?
 
const std::type_info & type () const
 Type_info for this object's held value.
 
int payloadSizeInBytes () const
 Size in bytes for this object's held value.
 
template<typename VALUETYPE >
const VALUETYPE * to_ptr () const
 Convert the held object to a pointer.
 
const void * to_void_ptr () const
 Convert held object to a const void *.
 
void * to_void_ptr ()
 Convert held object to a void *.
 
template<typename VALUETYPE >
VALUETYPE to_value () const
 Extract the data from the WxAny object.
 

Constructor & Destructor Documentation

◆ WxAny() [1/4]

WxAny::WxAny ( )
inline

Create empty object.

◆ WxAny() [2/4]

template<typename VALUETYPE >
WxAny::WxAny ( const VALUETYPE &  value)
inline

Create new WxAny from an object of a given type.

Parameters
valueValue of object stored.

◆ WxAny() [3/4]

WxAny::WxAny ( const WxAny other)
inline

Copy ctor.

◆ WxAny() [4/4]

WxAny::WxAny ( WxAny &&  other)
inlinenoexcept

move ctor

◆ ~WxAny()

WxAny::~WxAny ( )
inline

Member Function Documentation

◆ empty()

bool WxAny::empty ( ) const
inline

Is object empty?

◆ operator=() [1/3]

template<typename VALUETYPE >
WxAny & WxAny::operator= ( const VALUETYPE &  rhs)
inline

Assignment operator: use VALUETYPE object to create a new object.

◆ operator=() [2/3]

WxAny & WxAny::operator= ( const WxAny rhs)
inline

Assignment operator: use WxAny object to create a new object.

Parameters
rhsWxAny to assign from

◆ operator=() [3/3]

WxAny & WxAny::operator= ( WxAny &&  rhs)
inlinenoexcept

◆ payloadSizeInBytes()

int WxAny::payloadSizeInBytes ( ) const
inline

Size in bytes for this object's held value.

Returns size of stored type in bytes or -1 if no payload.

◆ swap()

WxAny & WxAny::swap ( WxAny rhs)
inline

Swap contents of object with contents of supplied object.

Parameters
rhsReplace the value in this WxAny with 'rhs'

◆ to_ptr()

template<typename VALUETYPE >
const VALUETYPE * WxAny::to_ptr ( ) const
inline

Convert the held object to a pointer.

Do not use this function directly without checking if the returned pointer is not NULL.

◆ to_value()

template<typename VALUETYPE >
VALUETYPE WxAny::to_value ( ) const
inline

Extract the data from the WxAny object.

If the type specified by the template 'VALUETYPE' is not the correct type of the object stored a std::bad_cast exception is thrown.

◆ to_void_ptr() [1/2]

void * WxAny::to_void_ptr ( )
inline

Convert held object to a void *.

This is not a safe operation as it breaks typechecking.

◆ to_void_ptr() [2/2]

const void * WxAny::to_void_ptr ( ) const
inline

Convert held object to a const void *.

This is not a safe operation as it breaks typechecking.

◆ type()

const std::type_info & WxAny::type ( ) const
inline

Type_info for this object's held value.


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