DCMTK  Version 3.6.2
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...
 

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;
}
};

Referenced by OFunique_ptr< DecoderStrategy >::OFunique_ptr().

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.

Referenced by OFunique_ptr< DecoderStrategy >::OFunique_ptr().

◆ 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 DSRTree< DSRDocumentTreeNode >::swap().


Generated on Mon Jul 17 2017 for DCMTK Version 3.6.2 by Doxygen 1.8.13