diff --git a/include/fixed_containers/random_access_iterator.hpp b/include/fixed_containers/random_access_iterator.hpp index 8620033d..a5f7ea88 100644 --- a/include/fixed_containers/random_access_iterator.hpp +++ b/include/fixed_containers/random_access_iterator.hpp @@ -161,7 +161,7 @@ class RandomAccessIterator friend constexpr Self operator+(difference_type n, const Self& other) { - return Self(std::next(other.iterator_, n)); + return Self{std::next(other, n)}; } constexpr Self& operator-=(difference_type n) diff --git a/include/fixed_containers/random_access_iterator_transformer.hpp b/include/fixed_containers/random_access_iterator_transformer.hpp index 5bc5c276..9fc4d995 100644 --- a/include/fixed_containers/random_access_iterator_transformer.hpp +++ b/include/fixed_containers/random_access_iterator_transformer.hpp @@ -138,7 +138,7 @@ class RandomAccessIteratorTransformer friend constexpr Self operator+(difference_type off, const Self& other) { - return Self(std::next(other.iterator_, off), other.unary_function_); + return Self{std::next(other.iterator_, off), other.unary_function_}; } constexpr Self& operator-=(difference_type off) diff --git a/test/fixed_circular_deque_test.cpp b/test/fixed_circular_deque_test.cpp index 84cad99d..98273424 100644 --- a/test/fixed_circular_deque_test.cpp +++ b/test/fixed_circular_deque_test.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,9 @@ static_assert(TriviallyCopyable); static_assert(NotTrivial); static_assert(StandardLayout); static_assert(IsStructuralType); + +static_assert(std::random_access_iterator); +static_assert(std::random_access_iterator); } // namespace trivially_copyable_vector struct ComplexStruct @@ -912,6 +916,9 @@ TEST(FixedCircularDeque, TrivialIterators) static_assert(*std::prev(v1.end(), 1) == 99); static_assert(*std::prev(v1.end(), 2) == 88); static_assert(*std::prev(v1.end(), 3) == 77); + + static_assert(*(1 + v1.begin()) == 88); + static_assert(*(2 + v1.begin()) == 99); } { @@ -1032,6 +1039,9 @@ TEST(FixedCircularDeque, ReverseIterators) static_assert(*std::prev(v1.rend(), 1) == 77); static_assert(*std::prev(v1.rend(), 2) == 88); static_assert(*std::prev(v1.rend(), 3) == 99); + + static_assert(*(1 + v1.begin()) == 88); + static_assert(*(2 + v1.begin()) == 99); } { diff --git a/test/fixed_deque_test.cpp b/test/fixed_deque_test.cpp index 3882599f..a5d1e08e 100644 --- a/test/fixed_deque_test.cpp +++ b/test/fixed_deque_test.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,10 @@ static_assert(TriviallyCopyable); static_assert(NotTrivial); static_assert(StandardLayout); static_assert(IsStructuralType); + +static_assert(std::random_access_iterator); +static_assert(std::random_access_iterator); + } // namespace trivially_copyable_deque struct ComplexStruct @@ -864,6 +869,9 @@ TEST(FixedDeque, TrivialIterators) static_assert(*std::prev(v1.end(), 1) == 99); static_assert(*std::prev(v1.end(), 2) == 88); static_assert(*std::prev(v1.end(), 3) == 77); + + static_assert(*(1 + v1.begin()) == 88); + static_assert(*(2 + v1.begin()) == 99); } { @@ -984,6 +992,9 @@ TEST(FixedDeque, ReverseIterators) static_assert(*std::prev(v1.rend(), 1) == 77); static_assert(*std::prev(v1.rend(), 2) == 88); static_assert(*std::prev(v1.rend(), 3) == 99); + + static_assert(*(1 + v1.rbegin()) == 88); + static_assert(*(2 + v1.rbegin()) == 77); } { diff --git a/test/fixed_string_test.cpp b/test/fixed_string_test.cpp index fa4c18db..f1f3971a 100644 --- a/test/fixed_string_test.cpp +++ b/test/fixed_string_test.cpp @@ -28,6 +28,9 @@ static_assert(NotTrivial); static_assert(StandardLayout); static_assert(IsStructuralType); +static_assert(std::contiguous_iterator); +static_assert(std::contiguous_iterator); + void const_span_ref(const std::span&) {} void const_span_of_const_ref(const std::span&) {} @@ -483,6 +486,9 @@ TEST(FixedString, TrivialIterators) static_assert(*std::prev(v1.end(), 1) == '9'); static_assert(*std::prev(v1.end(), 2) == '8'); static_assert(*std::prev(v1.end(), 3) == '7'); + + static_assert(*(1 + v1.begin()) == '8'); + static_assert(*(2 + v1.begin()) == '9'); } { @@ -551,6 +557,9 @@ TEST(FixedString, ReverseIterators) static_assert(*std::prev(v1.rend(), 1) == '7'); static_assert(*std::prev(v1.rend(), 2) == '8'); static_assert(*std::prev(v1.rend(), 3) == '9'); + + static_assert(*(1 + v1.begin()) == '8'); + static_assert(*(2 + v1.begin()) == '9'); } { diff --git a/test/fixed_vector_test.cpp b/test/fixed_vector_test.cpp index 300c5499..6437a08e 100644 --- a/test/fixed_vector_test.cpp +++ b/test/fixed_vector_test.cpp @@ -898,6 +898,9 @@ TEST(FixedVector, TrivialIterators) static_assert(*std::prev(v1.end(), 1) == 99); static_assert(*std::prev(v1.end(), 2) == 88); static_assert(*std::prev(v1.end(), 3) == 77); + + static_assert(*(1 + v1.begin()) == 88); + static_assert(*(2 + v1.begin()) == 99); } { @@ -1007,6 +1010,9 @@ TEST(FixedVector, ReverseIterators) static_assert(*std::prev(v1.rend(), 1) == 77); static_assert(*std::prev(v1.rend(), 2) == 88); static_assert(*std::prev(v1.rend(), 3) == 99); + + static_assert(*(1 + v1.begin()) == 88); + static_assert(*(2 + v1.begin()) == 99); } {