Simbody
3.5
|
This templatized type is used by the Array_<T,X> classes to obtain the information they need to use the class X as an index class for the array. More...
Public Types | |
typedef X::size_type | size_type |
The signed or unsigned integral type to which an object of index type X can be converted without producing any compiler warnings. More... | |
typedef X::difference_type | difference_type |
A signed integral type large enough to hold the full range of possible signed differences i-j between two indices i and j of type X. More... | |
Static Public Member Functions | |
static size_type | max_size () |
The maximum allowable size for any Array_<T,X> that uses this type X as its index type. More... | |
This templatized type is used by the Array_<T,X> classes to obtain the information they need to use the class X as an index class for the array.
There must be a specialization here providing ArrayIndexTraits for each of the built-in integral types that is suitable for use as an index. Any other type X will qualify as an index if it defines the following members:
max_size() determines the largest number of elements that a container may hold if its index type is X.
size_type must be an integral type large enough to hold all the values from 0 to max_size(), including all the index values (which range from 0 to max_size()-1). size_type may be signed or unsigned; it is the type returned by size(), max_size(), capacity(), etc. and may be compared directly against an index of type X without producing a compiler warning.
difference_type is a signed integral type that can hold all possible differences between two indices, that is, values between -(max_size()-1) and +(max_size()-1). In most cases we use an integral type with the same number of bits for size_type and difference_type but when the index type is very small (bool, unsigned char, or unsigned short) we want to allow the full range (2, 255, or 65535 elements, resp.) in which case we need a wider type to hold the differences.
The conversion operator ensures that we can write size_type(i) for an index i of type X. An explicit conversion member does not need to be present as long as the conversion size_type(i) already works as it does for all the integral type specializations.
The SimTK type-generating macro SimTK_DEFINE_UNIQUE_INDEX_TYPE() provides the necessary members so that these types can be used directly as index types for Array_ objects with no further preparation. For example, you can make an Array_<int,MobilizedBodyIndex> that stores ints that can be indexed only via MobilizedBodyIndex indices.
X | A type suitable for use as an Array_ index. |
typedef X::size_type SimTK::ArrayIndexTraits< X >::size_type |
The signed or unsigned integral type to which an object of index type X can be converted without producing any compiler warnings.
typedef X::difference_type SimTK::ArrayIndexTraits< X >::difference_type |
A signed integral type large enough to hold the full range of possible signed differences i-j between two indices i and j of type X.
|
inlinestatic |
The maximum allowable size for any Array_<T,X> that uses this type X as its index type.