// // Tests for // iterator begin(); // const_iterator begin() const; // // iterator end(); // const_iterator end() const; // #include #include "test_policy.h" #include #include struct T { int i; }; template static void tests() { // Check begin()/end() for a non-empty array { test_bounded_array array = {T{0}, T{1}, T{2}, T{3}, T{4}}; test_bounded_ptr begin = array.begin(); test_bounded_ptr end = array.end(); CHECK(begin.discard_bounds() == array.data()); CHECK(end.unsafe_discard_bounds() == array.data() + 5); } { test_bounded_array const array = {T{0}, T{1}, T{2}, T{3}, T{4}}; test_bounded_ptr begin = array.begin(); test_bounded_ptr end = array.end(); CHECK(begin.discard_bounds() == array.data()); CHECK(end.unsafe_discard_bounds() == array.data() + 5); } // Check begin()/end() for an empty array { test_bounded_array array = {}; test_bounded_ptr begin = array.begin(); test_bounded_ptr end = array.end(); CHECK(begin.unsafe_discard_bounds() == array.data()); CHECK(end.unsafe_discard_bounds() == array.data()); } { test_bounded_array const array = {}; test_bounded_ptr begin = array.begin(); test_bounded_ptr end = array.end(); CHECK(begin.unsafe_discard_bounds() == array.data()); CHECK(end.unsafe_discard_bounds() == array.data()); } // Check associated types { using A = test_bounded_array; static_assert(std::is_same_v >); static_assert(std::is_same_v >); } } T_DECL(begin_end, "bounded_array.begin_end", T_META_TAG_VM_PREFERRED) { tests(); }