5#include <system/object.h>
6#include <system/exceptions.h>
7#include <system/details/dereference.h>
8#include <system/details/slicing.h>
15class ASPOSECPP_SHARED_CLASS
Index :
public ::System::Details::BoxableObjectBase
17 RTTI_INFO_VALUE_TYPE(
Index)
21 constexpr Index() noexcept : m_value(0), m_is_from_end(false) {}
25 constexpr Index(int32_t value) noexcept : m_value(value), m_is_from_end(
false) {}
30 constexpr Index(int32_t value,
bool from_end) noexcept : m_value(value), m_is_from_end(from_end) {}
37 return Index(value,
true);
49 return Index(0,
true);
69 return m_is_from_end ? length - m_value : m_value;
77 return m_value == other.m_value && m_is_from_end == other.m_is_from_end;
100 auto& ref = Details::Dereference(collection);
101 auto length = Details::GetCollectionSize(ref);
Represents an index into a collection. The index can be from the start or from the end....
Definition: index.h:16
constexpr Index() noexcept
Constructs an instance that represents the start of a collection.
Definition: index.h:21
constexpr Index(int32_t value) noexcept
Constructs an instance that represents the specified position from the start of a collection.
Definition: index.h:25
int32_t GetHashCode() const
Returns a hash code for the current index.
Definition: index.h:82
constexpr bool get_IsFromEnd() const noexcept
Gets a value that indicates whether the index is from the end.
Definition: index.h:59
constexpr Index(int32_t value, bool from_end) noexcept
Constructs an instance that represents the specified index.
Definition: index.h:30
constexpr int32_t get_Value() const noexcept
Gets the index value.
Definition: index.h:53
int32_t GetOffset(int32_t length) const
Converts the current Index into an offset from the start of a collection with the specified length.
Definition: index.h:67
bool Equals(const Index &other) const
Determines whether the current instance and the specified Index represent the same position.
Definition: index.h:75
static constexpr Index FromEnd(int32_t value) noexcept
Creates an Index that is relative to the end of the collection.
Definition: index.h:35
static constexpr Index get_Start() noexcept
Gets an Index object representing the start of a collection.
Definition: index.h:41
static constexpr Index get_End() noexcept
Gets an Index object representing the end of a collection.
Definition: index.h:47
Definition: db_command.h:9
auto & Get(T &collection, const Index &index)
Implementation for collection[index] expressions.
Definition: index.h:98