I've run into a strange, and very specific issue. As some background, I need to support some legacy code that's passing around a lot of large c-style strings. Since these get pretty gigantic, I want to avoid unnecessarily copying that data, which would include copy constructing std::strings just for one operation.
I want to use std::sort on these strings, but they obviously lack iterators. However, according to the documentation for std::sort, I should just be able to pass in two pointers for any contiguous random access memory, but it isn't working with my c-style string
Basically it's like this:
char* foo = "test string";
std::sort(foo, foo + 11); // access violation occurs
However:
char foo[] = "test string";
std::sort(foo, foo + 11); // perfect fine, sorted correctly
This is extra confusing to me, because as far as I know, char* and char[] are essentially the same. Why does char* break, while char[] succeeds? How can I pass a c-style string into an STL algorithm?