DCMTK
Version 3.6.2
OFFIS DICOM Toolkit
|
A class template that implements generic tuples. More...
Related Definitions | |
Global types, methods and objects that are somehow related | |
const < unspecified > | OFignore |
A literal used in conjunction with OFtie to ignore specific elements. More... | |
template<typename Tuple > | |
< metafunction > | OFtuple_size |
A metafunction to determine the size of a tuple. More... | |
template<size_t Index, typename Tuple > | |
< metafunction > | OFtuple_element |
A metafunction to determine the type of one element of a tuple. More... | |
template<typename... Types> | |
OFtuple< typename OFdecay< Types >::type... > | OFmake_tuple (Types &&... args) |
Creates a tuple, automatically deducing the element types from the given arguments. More... | |
template<typename... Types> | |
OFtuple< Types &... > | OFtie (Types &... args) |
Creates a tuple of references to the given arguments. More... | |
template<size_t Index, typename Tuple > | |
OFtuple_element< Index, Tuple >::type & | OFget (Tuple &tuple) |
A function template to access an element of a tuple. More... | |
template<size_t Index, typename Tuple > | |
const OFtuple_element< Index, Tuple >::type & | OFget (const Tuple &tuple) |
A function template to access an element of a tuple. More... | |
A class template that implements generic tuples.
Types | a sequence of element types that shall be contained in the tuple. An empty sequence is allowed.
|
The term tuple type refers to the generic concept of tuples of elements, to be described as follows:
The following types provided by the DCMTK currently fulfill all the above requirements and may therefore be regarded as tuple types:
When C++11 support is enabled, OFtuple_size, OFtuple_element and OFget refer to the respective STL declarations and therefore std::array may then be regarded as a tuple type as well.
It is possible to define one's own tuple types, which may then be modified by all operations that are defined on tuple types as well. To define a custom tuple type, you need to implement the above accession methods, which means to specialize OFtuple_size and OFtuple_element and overload OFget in appropriate ways.
As described in the previous section tuple types are queried and modified by the freestanding metafunctions and function templates OFtuple_size, OFtuple_element and OFget. Regarding OFtuple, two additional function templates are provided: OFmake_tuple and OFtie. Take a look at the Related Definitions section for their description.
However, some operations are defined on OFtuple objects themselves, these are described in this section. But first we need to declare the following symbols, which are used in that description:
Symbol | Definition |
---|---|
T0, T1, ..., Tn | The elements' types of two (possibly) different tuples |
t0, t1, ..., tn | Objects of types T0, T1, ..., Tn respectively |
u0, u1, ..., un | Objects of types U0, U1, ..., Un respectively |
t, rhs | An object of type OFtuple<T0,T1,...,Tn> |
u | An object of type OFtuple<U0,U1,...,Un> |
t2 | An object of type OFtuple<T0,T1> , a tuple with exactly two elements |
p | An object of type OFPair<U0,U1> |
The allowed syntax on OFtuple objects is described in the following table:
Expression | Meaning |
---|---|
t == u, u == t | Compares the tuples t and u for equality / inequality. You may compare tuples with different element types, as long as both elements at the same index are comparable (overload operator== rsp. operator!= ).
|
t < u, u > t | Tests if the tuples t and u are less / less or equal to each other. You may compare tuples with different element types, as long as both elements at the same index are comparable (overload operator< rsp. operator<= ).
|
OFtuple<T0,T1,...,Tn> t | Constructs a tuple containing the supplied arguments as its elements (if any). The elements' types T0, T1, ..., Tn must be specified explicitly unless OFmake_tuple is used, which deduces appropriate types from the given parameters t0, t1, ..., tn .If C++11 support is available, t may be move constructed from whatever arguments were supplied, possibly increasing the performance.
|
t = rhs | Assigns the elements from another tuple type to the elements in the left hand side OFtuple object. If C++11 support is available, the elements may be move assigned instead of being copied, possibly increasing the performance. |
t.swap( rhs ) | Swaps the elements of two OFtuple objects with identical element types. Effectively calls OFswap() on each pair of elements that share the same index. Note however that this is done sequentially, at no time requiring a whole copy of one the tuples to reside in the memory. |
Output:
The following tuples are inequal: Hello World, 42 , 0 The following tuples are equal: Hello World, 42 Hello World, 42 Hello World, 42 This, is, a, tuple, with, 7, elements
|
related |
A function template to access an element of a tuple.
Index | the index of the element that should be accessed. |
Tuple | a tuple type, e.g. an instance of OFtuple. This parameter is deduced automatically. |
tuple | a reference to the tuple to access an element of. |
Index < OFtuple_size<Tuple>::value
.
|
related |
A function template to access an element of a tuple.
Index | the index of the element that should be accessed. |
Tuple | a tuple type, e.g. an instance of OFtuple. This parameter is deduced automatically. |
tuple | a const reference to the tuple to access an element of. |
Index < OFtuple_size<Tuple>::value
. Output:
Homer Simpson, age 38 is male.
|
related |
A literal used in conjunction with OFtie to ignore specific elements.
OFignore is a global constant that "tags" a specific tuple element which should be ignored. This means anything can be assigned to this element without any effect.
|
related |
Creates a tuple, automatically deducing the element types from the given arguments.
args | a sequence of arguments. When no arguments are supplied, an object of type OFtuple<> is created.
|
OFcreate_tuple deduces the element types from the arguments by applying OFdecay to each parameter type.
|
related |
Creates a tuple of references to the given arguments.
args | a sequence of arguments. When no arguments are supplied, an object of type OFtuple<> is created.
|
OFtie is meant to link its arguments to an OFtuple object, to ease extracting the elements from a tuple.
|
related |
A metafunction to determine the type of one element of a tuple.
Index | the index of the element its type should be determined. |
Tuple | a tuple type, e.g. an instance of OFtuple. |
Index < OFtuple_size<Tuple>::value
. A metafunction to determine the size of a tuple.
Tuple | a tuple type, e.g. an instance of OFtuple. |
Output:
OFtuple_size<MyTuple>::value: 3 OFtuple_size<MyPair>::value: 2