DCMTK Version 3.7.0 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

  Alternative | the chosen alternative that shall be accessed.
  Alternatives | the alternatives the given variant could hold, will be deduced automatically.

Parameters

  v | a 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!
}
OFvariant
A class template that represents a type-safe union.
Definition: ofvriant.h:417

## ◆ 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

  Alternative | the chosen alternative that shall be accessed.
  Alternatives | the alternatives the given variant could hold, will be deduced automatically.

Parameters

  v | a 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:

OFvariant<int,OFString> v;
// ... 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 Mon Dec 15 2025 for DCMTK Version 3.7.0 by Doxygen 1.9.1