DCMTK  Version 3.6.5
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< Tuple >
 
struct  OFtuple_element< Index, Tuple >
 
struct  OFtuple_size< OFPair< K, V > >
 
struct  OFtuple_element< 0, OFPair< K, V > >
 
struct  OFtuple_element< 1, OFPair< K, V > >
 
struct  OFpair_element< Element >
 
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_size

struct OFtuple_size

template<typename Tuple>
struct OFtuple_size< Tuple >

◆ OFtuple_element

struct OFtuple_element

template<size_t Index, typename Tuple>
struct OFtuple_element< Index, Tuple >

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

◆ OFpair_element

struct OFpair_element

template<size_t Element>
struct OFpair_element< Element >

Macro Definition Documentation

◆ OFrvalue_ref

#define OFrvalue_ref (   T)    unspecified

Determines rvalue reference type for the type T.

Parameters
Tthe 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_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
Tthe base class to upcast to
RVthe 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
tThe object to move.
See also
OFrvalue
OFrvalue_ref

◆ 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
rvan rvalue reference, e.g. the parameter of a move constructor.

◆ 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
t0An object to be exchanged.
t1The object to be exchanged with t0.

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


Generated on Mon Oct 28 2019 for DCMTK Version 3.6.5 by Doxygen 1.8.15