-
#include "tensorstore/index_space/dimension_identifier.h"
- class tensorstore::DimensionIdentifier;
Specifies a dimension of an index space by index or by label.
Conceptually similar to
std::variant<DimensionIndex, std::string_view>
.Constructors¶
- DimensionIdentifier();
Constructs an invalid dimension identifier.
- constexpr DimensionIdentifier(DimensionIndex index);
Constructs from a dimension index.
- constexpr DimensionIdentifier(std::string_view label);
Constructs from a label.
Methods¶
- constexpr DimensionIndex index() const;
Returns the specified dimension index, or
std::numeric_limits<DimensionIndex>::max()
if a dimension label was specified.
- constexpr std::string_view label() const;
Returns the dimension label, or a label with
data() == nullptr
if a dimension index was specified.
Friend functions¶
-
friend bool operator==(const DimensionIdentifier& a,
const DimensionIdentifier& b); -
friend bool operator!=(const DimensionIdentifier& a,
const DimensionIdentifier& b); Compares two dimension identifiers.
-
friend std::ostream&
operator<<(std::ostream& os, const DimensionIdentifier& x); Prints to an
std::ostream
.
Related Functions¶
-
Result<DimensionIndex>
tensorstore::NormalizeDimensionIndex(DimensionIndex index,
DimensionIndex rank); Normalizes a dimension index in the range
(-rank, rank)
to the range[0, rank)
.
-
Result<DimensionIndex>
tensorstore::NormalizeDimensionLabel(std::string_view label,
span<const std::string> labels); -
Result<DimensionIndex> tensorstore::NormalizeDimensionLabel(
std::string_view label,
span<const std::string_view> labels); Converts a dimension label to a dimension index.
-
Result<DimensionIndex> tensorstore::NormalizeDimensionIdentifier(
DimensionIdentifier identifier,
span<const std::string> labels); Normalizes a dimension identifier to a dimension index in the range
[0, rank)
.