DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Classes | Macros | Functions
ofutil.h File Reference

Implement fallback support for modern techniques defined in the STL's <utility> header (e.g. move semantics) for older compilers. More...

## Classes
struct | OFrvalue< T >
| A helper class to 'tag' objects as rvalues to help DCMTK's move emulation employed on pre C++11 compilers. More...
class | OFPair< K, V >
| a pair - this implements parts of std::pair's interface. More...
struct | OFtuple_size< OFPair< K, V > >
struct | OFtuple_element< 0, OFPair< K, V > >
struct | OFtuple_element< 1, OFPair< K, V > >
struct | OFpair_element< 0 >
struct | OFpair_element< 1 >

## Macros
#define | OFrvalue_ref(T) unspecified
| Determines rvalue reference type for the type `T`. More...
#define | OFrvalue_ref_upcast(T, RV) unspecified
| Upcast an rvalue reference to an rvalue reference of one of its bases. More...

## Functions
template<typename T >
T & | OFrvalue_access (OFrvalue_ref(T) rv)
| Obtain an lvalue reference from an rvalue reference. More...
template<typename T >
OFconstexpr xvalue | OFmove (T< unspecified > t)
| Obtains an rvalue reference to its argument and converts it to an xvalue. More...
template<typename T >
void | OFswap (T &t0, T &t1)
| Exchanges the given values. More...

## Detailed Description

Implement fallback support for modern techniques defined in the STL's <utility> header (e.g. move semantics) for older compilers.

## Class Documentation

## ◆ OFtuple_element< 0, OFPair< K, V > >

struct OFtuple_element< 0, OFPair< K, V > >

### template<typename K, typename V>
struct OFtuple_element< 0, OFPair< K, V > >

## ◆ OFtuple_element< 1, OFPair< K, V > >

struct OFtuple_element< 1, OFPair< K, V > >

### template<typename K, typename V>
struct OFtuple_element< 1, OFPair< K, V > >

## Macro Definition Documentation

## ◆ OFrvalue_ref

#define OFrvalue_ref | ( |  | T | ) | unspecified

Determines rvalue reference type for the type `T`.

Parameters

  T | the base type to determine the rvalue reference type for.

Note
  OFrvalue_ref(T) will expand to `T&&` when C++11 support is available. Otherwise DCMTK's move emulation will be used, employing an unspecified type to implement rvalue references.

## Example

This example shows how to implement the move constructor and move assignment for a custom class in a portable fashion (employing C++11's native features when available and using DCMTK's move emulation otherwise).

class MyMovable
{
public:
MyMovable( OFrvalue_ref(MyMovable) rhs )
: m_hDatabase( rhs.m_hDatabase )
{
// You need to use OFrvalue_access to get write access
// to rvalue references when DCMTK's move emulation
// is used.
OFrvalue_access(rhs).m_hDatabase = OFnullptr;
}
MyMovable& operator=( OFrvalue_ref(MyMovable) rvrhs )
{
// You may bind the rvalue reference to an lvalue
// reference to ease access.
MyMovable& rhs = OFrvalue_access(rvrhs);
if( this != &rhs )
{
disconnectDatabase( m_hDatabase );
m_hDatabase = rhs.m_hDatabase;
rhs.m_hDatabase = OFnullptr;
}
return *this;
}
};
OFrvalue_access
T & OFrvalue_access(OFrvalue_ref(T) rv)
Obtain an lvalue reference from an rvalue reference.
Definition: ofutil.h:241
OFrvalue_ref
#define OFrvalue_ref(T)
Determines rvalue reference type for the type T.
Definition: ofutil.h:214

## ◆ OFrvalue_ref_upcast

#define OFrvalue_ref_upcast | ( |  | T,
|  |  | RV
| ) |  | unspecified

Upcast an rvalue reference to an rvalue reference of one of its bases.

This is a helper macro for being used with DCMTK's fallback implementation of move semantics. C++11 rvalue references should normally allow implicit upcasts, therefore, this macro typically has no effect if C++11 is enabled (it may be used to work around the behavior of older GCC versions).

Parameters

  T | the base class to upcast to
  RV | the rvalue reference to upcast

## Function Documentation

## ◆ OFmove()

template<typename T >

OFconstexpr xvalue OFmove | ( | T< unspecified > | t | ) |

Obtains an rvalue reference to its argument and converts it to an xvalue.

OFmove is meant to 'mark' an object for a move operation, e.g. to move an OFVector object into another OFVector instance instead of copying it.

Note
  OFmove will be an alias for std::move when native move semantics are supported (C++11 support is available). Otherwise DCMTK's move emulation will be used. This means you will have to specify rvalues (e.g. function return values) employing the OFrvalue class template.

Parameters

  t | The object to move.

See also
  OFrvalue
  OFrvalue_ref

Referenced by OFswap().

## ◆ OFrvalue_access()

template<typename T >

T& OFrvalue_access | ( | OFrvalue_ref(T) | rv | ) |

Obtain an lvalue reference from an rvalue reference.

DCMTK's move emulations does restrict write access to rvalue references due to compiler limitations. This method enables you to workaround this restriction by converting DCMTK's emulated rvalue references to lvalue references.

Note
  Native rvalue references from C++11 don't need this workaround, therefore OFrvalue_access has no effect when C++11 support is available.

Parameters

  rv | an rvalue reference, e.g. the parameter of a move constructor.

Referenced by OFunique_ptr< T >::OFunique_ptr(), and OFunique_ptr< T >::operator=().

## ◆ OFswap()

template<typename T >

void OFswap | ( | T & | t0,
|  | T & | t1
| ) |  |

Exchanges the given values.

OFswap is an alias for std::swap if C++11 is supported. Otherwise OFswap simply creates a temporary copy of one argument to exchange both values.

Note
  As intended for std::swap, there are some specializations for OFswap available, e.g. for OFoptional, which specializes OFswap to exchange optional objects more efficiently. When creating your own specializations for OFswap, make sure to specialize std::swap instead when C++11 support is available.

Parameters

  t0 | An object to be exchanged.
  t1 | The object to be exchanged with t0.

References OFmove().

Referenced by DSRTree< T >::swap(), and DSRTreeNodeCursor< T >::swap().

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