DCMTK Version 3.7.0 OFFIS DICOM Toolkit

OFrvalue< T > Struct Template Reference

A helper class to 'tag' objects as rvalues to help DCMTK's move emulation employed on pre C++11 compilers. More...

Inheritance diagram for OFrvalue< T >:

## Detailed Description

### template<typename T>
struct OFrvalue< T >

A helper class to 'tag' objects as rvalues to help DCMTK's move emulation employed on pre C++11 compilers.

Template Parameters

  T | the base type an rvalue should be create of.

OFrvalue wraps the type T inside a zero-overhead object employing T's move constructor when possible.

Note
  When C++11 support is available, OFrvalue<T> will simply be a type alias for T, since a C++11 compiler handles rvalue reference conversions natively.

## Example

This example describes how to move an object of type OFunique_ptr out of a function by using OFrvalue.

OFrvalue<OFunique_ptr<DcmDataset> > getDataset()
{
return OFunique_ptr<DcmDataset>( new DcmDataset );
}
. . .
OFunique_ptr<DcmDataset> pDataset = getDataset();
DcmDataset
a class handling the DICOM dataset format (files without meta header)
Definition: dcdatset.h:42
OFunique_ptr
OFunique_ptr is a smart pointer that retains sole ownership of an object through a pointer and destro...
Definition: ofmem.h:285
OFrvalue
A helper class to 'tag' objects as rvalues to help DCMTK's move emulation employed on pre C++11 compi...
Definition: ofutil.h:157

Warning
  Some compilers might require you to use the following code instead, as older versions of the C++ standard allowed the compiler to use the copy constructor for binding an rvalue to an lvalue reference. Use this code template instead to achieve maximum portability:
  OFrvalue<OFunique_ptr<DcmDataset> > getDataset()
  {
  OFunique_ptr<DcmDataset> pDataset( new DcmDataset );
  return OFmove( pDataset );
  }
  OFmove
  OFconstexpr xvalue OFmove(T< unspecified > t)
  Obtains an rvalue reference to its argument and converts it to an xvalue.

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

- ofstd/include/dcmtk/ofstd/ofutil.h

Generated on Mon Dec 15 2025 for DCMTK Version 3.7.0 by Doxygen 1.9.1