PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | Static Public Member Functions | Related Functions | List of all members
PIVariantSimple Class Reference

Lightweight strongly-typed variant for a single value. More...

#include <pivariantsimple.h>

Public Member Functions

 PIVariantSimple ()
 Constructs an empty PIVariantSimple.
 
 PIVariantSimple (const PIVariantSimple &v)
 Constructs a copy of PIVariantSimple.
 
 ~PIVariantSimple ()
 Destroys the stored value, if any.
 
PIVariantSimpleoperator= (const PIVariantSimple &v)
 Replaces this object with a copy of another PIVariantSimple.
 
template<typename T >
void setValue (const T &v)
 Stores value v. More...
 
template<typename T >
value () const
 Returns the stored value as type T. More...
 

Static Public Member Functions

template<typename T >
static PIVariantSimple fromValue (const T &v)
 Creates PIVariantSimple initialized with value v.
 

Related Functions

(Note that these are not member functions.)

#define REGISTER_PIVARIANTSIMPLE(Type)
 Registers a readable type name for PIVariantSimple.
 

Detailed Description

Lightweight strongly-typed variant for a single value.

Member Function Documentation

◆ setValue()

template<typename T >
void PIVariantSimple::setValue ( const T &  v)
inline

Stores value v.

Reuses the existing storage when the stored type already matches T.

◆ value()

template<typename T >
T PIVariantSimple::value ( ) const
inline

Returns the stored value as type T.

Unlike PIVariant, this class checks the exact stored type. Returns the value only when the currently stored type matches T.