diff --git a/include/etl/multi_span.h b/include/etl/multi_span.h index c24e893a1..7f98865dc 100644 --- a/include/etl/multi_span.h +++ b/include/etl/multi_span.h @@ -134,7 +134,7 @@ namespace etl //************************************************************************* pointer operator ->() { - return *p_value; + return &operator*(); } //************************************************************************* @@ -142,7 +142,7 @@ namespace etl //************************************************************************* const_pointer operator ->() const { - return *p_value; + return &operator*(); } //************************************************************************* diff --git a/test/test_multi_span.cpp b/test/test_multi_span.cpp index a327ff861..d59c8d758 100644 --- a/test/test_multi_span.cpp +++ b/test/test_multi_span.cpp @@ -33,6 +33,7 @@ SOFTWARE. #include #include +#include namespace { @@ -46,6 +47,14 @@ namespace int data7[1]; int data8[2]; + struct Data + { + int i; + }; + + Data struct_data1[] = {Data{1}, Data{2}, Data{3}}; + Data struct_data2[] = {Data{4}, Data{5}, Data{6}}; + SUITE(test_multi_span) { //************************************************************************* @@ -140,5 +149,30 @@ namespace std::copy(expected.begin(), expected.end(), ms_int.begin()); CHECK(std::equal(expected.begin(), expected.end(), ms_int.begin())); } + + //************************************************************************* + TEST(test_member_pointer_operator) + { + std::vector> span_list = + { + etl::span(struct_data1), + etl::span(struct_data2) + }; + + etl::multi_span ms_data(etl::multi_span::span_list_type(std::begin(span_list), std::end(span_list))); + + etl::multi_span::iterator itr = ms_data.begin(); + CHECK_EQUAL(struct_data1[0].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data1[1].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data1[2].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data2[0].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data2[1].i, itr->i); + ++itr; + CHECK_EQUAL(struct_data2[2].i, itr->i); + } }; }