Loading...
Searching...
No Matches
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.
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.

## 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::OFvariant
OFvariant()
Constructs a variant holding a default constructed value of the first alternative.
OFvariant::OFget
Alternative * OFget(OFvariant< Alternatives... > *v)
Try to get a pointer to the given alternative from an OFvariant object.

## 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 for DCMTK Version 3.7.0 by Doxygen 1.15.0