DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Tools for in-place construction

#include "dcmtk/ofstd/ofutil.h"
Tools for in-place construction of objects, e.g. certain OFvariant alternatives.

## Type Definitions
typedef unspecified | OFin_place_t
| A type for tagging an in-place constructor as such. More...
template<typename T>
typedef unspecified | OFin_place_type_t(T)
| A type for tagging an in-place constructor for a certain type as such. More...
template<size_t I>
typedef unspecified | OFin_place_index_t(I)
| A type for tagging an in-place constructor based on a certain index as such. More...

## Global Constants
OFin_place_t | OFin_place
| A constant of type OFin_place_t that may be used for in-place construction. More...
template<typename T>
OFin_place_type_t(T) | OFin_place<T>
| A constant of type OFin_place_type_t(T) that may be used for in-place construction. More...
template<size_t I>
OFin_place_index_t(I) | OFin_place<I>
| A constant of type OFin_place_index_t(I) that may be used for in-place construction. More...

## Type Definition Documentation

typedef unspecified OFin_place_t
A type for tagging an in-place constructor as such.

Usage Example:
template<typename T>
class Wrapper
{
public:
// Will copy construct the wrapped value from a T.
Wrapper( const T& t );
// Will in-place construct the value from the given arguments,
// calling T( arguments... ) internally, without unnecessary
// copies.
template<typename... Arguments>
Wrapper( OFin_place_t, Arguments... arguments );
private:
// ... wrapper implementation ...
};

template<typename T>
typedef unspecified OFin_place_type_t(T)
A type for tagging an in-place constructor for a certain type as such.

Template Parameters
  T the type this in-pace constructor handles, i.e. the type that will be constructed.

Note
  Pre C++11 compilers do not support alias templates, therefore, OFin_place_type_t is implemented using preprocessor macros internally. This is why you need to use curved brackets instead of angled ones.

Usage Example:
template<typename A,typename B>
class Union
{
public:
// Will copy construct the wrapped value as an A from a.
Union( const A& a );
// Will copy construct the wrapped value as a B from b.
Union( const B& b );
// Will in-place construct the value as an A from the given
// arguments, calling A( arguments... ) internally, without
// unnecessary copies.
template<typename... Arguments>
Union( OFin_place_type_t(A), Arguments... arguments );
// Will in-place construct the value as a B from the given
// arguments, calling B( arguments... ) internally, without
// unnecessary copies.
template<typename... Arguments>
Union( OFin_place_type_t(B), Arguments... arguments );
private:
// ... union implementation ...
};

template<size_t I>
typedef unspecified OFin_place_index_t(I)
A type for tagging an in-place constructor for a certain index as such.

Template Parameters
  I the index this in-pace constructor handles, i.e. the zero based index of the type that will be constructed.

Note
  Pre C++11 compilers do not support alias templates, therefore, OFin_place_index_t is implemented using preprocessor macros internally. This is why you need to use curved brackets instead of angled ones.

Usage Example:
template<typename A,typename B>
class Union
{
public:
// Will copy construct the wrapped value as an A from a.
Union( const A& a );
// Will copy construct the wrapped value as a B from b.
Union( const B& b );
// Will in-place construct the value as an A from the given
// arguments, calling A( arguments... ) internally, without
// unnecessary copies.
// This will even work if A and B refer to the same type.
template<typename... Arguments>
Union( OFin_place_index_t(0), Arguments... arguments );
// Will in-place construct the value as a B from the given
// arguments, calling B( arguments... ) internally, without
// unnecessary copies.
// This will even work if A and B refer to the same type.
template<typename... Arguments>
Union( OFin_place_index_t(1), Arguments... arguments );
private:
// ... union implementation ...
};

## Global Constant Documentation

OFin_place_t OFin_place
A constant of type OFin_place_t that may be used for in-place construction.

Remarks
  OFin_place is actually an overloaded function, but instead of calling it (which one should never do), its address is used as a tag, since the type of its address differs depending on which overload and template parameters are used. See http://en.cppreference.com/w/cpp/utility/in_place for more information.

Usage Example:
template<typename T>
class Wrapper; // see OFin_place_t example
// ...
// will construct an OFString and then copy construct the value in the wrapper
Wrapper<OFString>( "Hello World" );
// will in-place construct the value in the wrapper
Wrapper<OFString>( OFin_place, "Hello World" );
// this also works with multiple arguments:
// will take only the fist five characters of the const char*
Wrapper<OFString>( OFin_place, "Hello World", 5 );

template<typename T>
OFin_place_type_t(T) OFin_place<T>
A constant of type OFin_place_type_t(T) that may be used for in-place construction.

Template Parameters
  T the type for selecting an in-pace constructor, i.e. the type that will be constructed.

Remarks
  OFin_place is actually an overloaded function, but instead of calling it (which one should never do), its address is used as a tag, since the type of its address differs depending on which overload and template parameters are used. See http://en.cppreference.com/w/cpp/utility/in_place for more information.

Usage Example:
template<typename A,typename B>
class Union; // see OFin_place_type_t example
// ...
// will construct an OFString and then copy construct the value inside the union
Union<int,OFString>( OFString( "Hello World" ) );
// will in-place construct an OFString value inside the union
// with only the fist five characters
Union<int,OFString>( OFin_place<OFString>, "Hello World", 5 );
// will construct an integer value inside the union by casting
// the address of the character array constant to int
Union<int,OFString>( OFin_place<int>, "Hello World" );
OFString
a simple string class that implements a subset of std::string.
Definition: ofstring.h:76

template<size_t I>
OFin_place_index_t(I) OFin_place<I>
A constant of type OFin_place_index_t(I) that may be used for in-place construction.

Template Parameters
  I the index for selecting an in-pace constructor, i.e. the zero based index of the type that will be constructed.

Remarks
  OFin_place is actually an overloaded function, but instead of calling it (which one should never do), its address is used as a tag, since the type of its address differs depending on which overload and template parameters are used. See http://en.cppreference.com/w/cpp/utility/in_place for more information.

Usage Example:
template<typename A,typename B>
class Union; // see OFin_place_index_t example
// ...
// error, cannot determine which constructor shall be used,
// since both take an int
Union<int,int>( 3 );
// will in-place construct an int value inside the union
// tagging it as an A
Union<int,int>( OFin_place<0>, 3 );
// will in-place construct an int value inside the union
// tagging it as a B
Union<int,int>( OFin_place<1>, 3 );

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