I am trying to compile some code that was originally build in MS Visual Studio C++ 6.0 with Visual Studio 2013.
In the old code the following construct was often used for various data types (here for example for a string):
std::string someString;
someString = ....;
callSomeFunction(someString.begin().base());
So in order to enable the function to edit (in this example the string) the original buffer, the method begin()
gets an iterator for it and the method base()
returned a pointer to the first element of the buffer.
In the code this is not only used for strings, but for many many other datatypes as well.
Thus I was wondering, if there was a change to the standard library so the base()
method is no longer supported?
Is there any replacement for it? Or do I have to change the code here? Since this was used very frequently, I would prefer to find a simpler solution to this.
Currently I get an error like:
Error 3 error C2039: 'base' : is not a member of 'std::_Vector_iterator>>'
base
was not standardized for container iterators. It exists for iterator adaptors such as std::reverse_iterator
and std::move_iterator
. Microsoft had to remove it from their implementation in order to comply with the ISO C++ standard.
To obtain a pointer from a container iterator, simply use &* iter
. To get a pointer to the first element of the contiguous array backing a container, use cont.data()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With