#include <xtd/xtd>
auto main() -> int {
auto a = array {1, 2, 3, 4, 5};
try {
println("a[-1] = {}", a[-1]);
} catch (const index_out_of_range_exception& e) {
println("a[-1] Throws {}", e);
}
println("a[0] = {}", a[0]);
println("a[1] = {}", a[1]);
println("a[2] = {}", a[2]);
println("a[3] = {}", a[3]);
println("a[4] = {}", a[4]);
try {
println("a[5] = {}", a[5]);
} catch (const index_out_of_range_exception& e) {
println("a[5] Throws {}", e);
}
println();
try {
} catch (const index_out_of_range_exception& e) {
println("a[xtd::index::start-1] Throws {}", e);
}
try {
} catch (const index_out_of_range_exception& e) {
println("a[xtd::index::start+5] Throws {}", e);
}
println();
try {
println("a[~0_i] = {}", a[~0_i]);
} catch (const index_out_of_range_exception& e) {
println("a[~0_i] Throws {}", e);
}
println("a[~1_i] = {}", a[~1_i]);
println("a[~2_i] = {}", a[~2_i]);
println("a[~3_i] = {}", a[~3_i]);
println("a[~4_i] = {}", a[~4_i]);
println("a[~5_i] = {}", a[~5_i]);
try {
println("a[~6_i] = {}", a[~6_i]);
} catch (const index_out_of_range_exception& e) {
println("a[~6_i] Throws {}", e);
}
println();
try {
println("a[-1_i] = {}", a[-1_i]);
} catch (const index_out_of_range_exception& e) {
println("a[-1_i] Throws {}", e);
}
println("a[-2_i] = {}", a[-2_i]);
println("a[-3_i] = {}", a[-3_i]);
println("a[-4_i] = {}", a[-4_i]);
println("a[-5_i] = {}", a[-5_i]);
println("a[-6_i] = {}", a[-6_i]);
try {
println("a[-7_i] = {}", a[-7_i]);
} catch (const index_out_of_range_exception& e) {
println("a[-7_i] Throws {}", e);
}
println();
try {
} catch (const index_out_of_range_exception& e) {
println("a[xtd::index::last+1] Throws {}", e);
}
try {
} catch (const index_out_of_range_exception& e) {
println("a[xtd::index::last-5] Throws {}", e);
}
println();
try {
} catch (const index_out_of_range_exception& e) {
println("a[xtd::index::end] Throws {}", e);
}
}
static const index start
Represents the index of the first valid element in a collection.
Definition index.hpp:172
static const index end
Represents a value that is not a valid position in a collection.
Definition index.hpp:136
static const index last
Represents the index of the last valid element in a collection.
Definition index.hpp:154