'base' is not a member of an iterator in C ++ anymore

I am trying to compile some code that was originally created in MS Visual Studio C ++ 6.0 with Visual Studio 2013.

In the old code, the following construction was used for different data types (here, for example, for a string):

std::string someString;
someString = ....;
callSomeFunction(someString.begin().base());

So, to allow the function to edit (in this example, a string) the original buffer, the method begin()receives an iterator for it, and the method base()returns a pointer to the first element of the buffer.

In code, this is not only used for strings, but also for many other data types. So, I was wondering if a change was made to the standard library, so the method is base()no longer supported?

Is there a replacement for this? Or do I need to change the code here? Since this has been used very often, I would rather find a simpler solution.

I am currently getting the error message:

Error 3 of error C2039: 'base': is not a member of 'std :: _ Vector_iterator β†’'

+4
source share
2 answers

basenot standardized for container iterators. It exists for iterator adapters such as std::reverse_iteratorand std::move_iterator. Microsoft had to remove it from its implementation in order to comply with the ISO C ++ standard.

, &* iter. , , cont.data().

+7

:

callSomeFunction(&someString[0]);

char*. , , std::string& - , - , someString. , .

0

Source: https://habr.com/ru/post/1570464/


All Articles