вот мой код #pragma once #include <vector> #include <algorithm> #include <cstddef>…
- User
вот мой код #pragma once #include #include #include #include
template class FlattenedVector { public: using iterator_category = std::random_access_iterator_tag; using value_type = T; using difference_type = std::ptrdiff_t; using pointer = T*; using reference = T&;
code - Assistant
- User
теперь выдает такую ошибку main.cpp: In function 'void TestModify()': main.cpp:203:13: error: assignment of read-only location 'it.FlattenedVector::Iterator::operator*()' 203 | it = new_value; | ~~~~^~~~~~~~~~~ main.cpp:207:15: error: assignment of read-only location 'it.FlattenedVector::Iterator::operator' 207 | it[1] = value; In file included from main.cpp:1: flatten.h: In instantiation of 'T& FlattenedVector::Iterator::operator() [with T = long int]': main.cpp:79:54: required from here flatten.h:45:44: error: binding reference of type 'long int&' to 'const long int' discards qualifiers 45 | return parent_->at(ind_); | ^ flatten.h: In instantiation of 'T& FlattenedVector::Iterator::operator*() [with T = int]': main.cpp:93:9: required from here flatten.h:45:44: error: binding reference of type 'int&' to 'const int' discards qualifiers flatten.h: In instantiation of 'T& FlattenedVector::Iterator::operator [with T = int; std::ptrdiff_t = long int]': main.cpp:157:5: required from here flatten.h:105:48: error: binding reference of type 'int&' to 'const int' discards qualifiers 105 | return parent_->at(ind_ + n); | ^ flatten.h: In instantiation of 'T& FlattenedVector::Iterator::operator*() [with T = {anonymous}::TestData]': main.cpp:189:23: required from here flatten.h:45:44: error: binding reference of type '{anonymous}::TestData&' to 'const {anonymous}::TestData' discards qualifiers 45 | return parent_->at(ind_); | ^ flatten.h: In instantiation of 'T& FlattenedVector::Iterator::operator*() [with T = char]': main.cpp:208:9: required from here flatten.h:45:44: error: binding reference of type 'char&' to 'const char' discards qualifiers flatten.h: In instantiation of 'T& FlattenedVector::Iterator::operator*() [with T = long unsigned int]': main.cpp:244:13: required from here flatten.h:45:44: error: binding reference of type 'long unsigned int&' to 'const long unsigned int' discards qualifiers
- Assistant