DCMTK  Version 3.6.7
OFFIS DICOM Toolkit
Functions
OFget – OFvariant

Get a pointer to the value stored in an OFvariant holding the selected alternative. More...

Functions

template<typename Alternative , typename... Alternatives>
Alternative * OFget (OFvariant< Alternatives... > *v)
 Try to get a pointer to the given alternative from an OFvariant object. More...
 
template<typename Alternative , typename... Alternatives>
const Alternative * OFget (const OFvariant< Alternatives... > *v)
 Try to get a pointer to the given alternative from an OFvariant object. More...
 

Detailed Description

Get a pointer to the value stored in an OFvariant holding the selected alternative.

See also
OFvisit – Apply a visitor to an OFvariant object.

Function Documentation

◆ OFget() [1/2]

template<typename Alternative , typename... Alternatives>
const Alternative * OFget ( const OFvariant< Alternatives... > *  v)
related

Try to get a pointer to the given alternative from an OFvariant object.

Template Parameters
Alternativethe chosen alternative that shall be accessed.
Alternativesthe alternatives the given variant could hold, will be deduced automatically.
Parameters
va const reference to an OFvariant object potentially holding Alternative.
Returns
the address of the contained value of type const Alternative if such a value is contained. OFnullptr otherwise.

Usage Example:

const OFvariant<int,OFString> v( ... some value is assigned to v ... );
if( int* pI = OFget<int>( v ) ) // error, the result is const!
if( const int* pI = OFget<int>( v ) ) // OK
{
COUT << "Yes, it really is an int with the value " << *pI << '!' << OFendl;
*pI = "27"; // Error, *pI is const!
}
A class template that represents a type-safe union.
Definition: ofvriant.h:414

◆ OFget() [2/2]

template<typename Alternative , typename... Alternatives>
Alternative * OFget ( OFvariant< Alternatives... > *  v)
related

Try to get a pointer to the given alternative from an OFvariant object.

Template Parameters
Alternativethe chosen alternative that shall be accessed.
Alternativesthe alternatives the given variant could hold, will be deduced automatically.
Parameters
va reference to an OFvariant object potentially holding Alternative.
Returns
the address of the contained value of type Alternative if such a value is contained. OFnullptr otherwise.

Usage Example:

// ... some value is assigned to v ...
if( int* pI = OFget<int>( v ) )
{
COUT << "Yes, it really is an int with the value " << *pI << '!' << OFendl;
*pI = "27"; // now, let's directly assign something else
}


Generated on Thu Apr 28 2022 for DCMTK Version 3.6.7 by Doxygen 1.9.1