I can imagine some legacy code that uses const char*. |
Yes, old code from before 1998 and some past it for holdouts (there were reasons for a while) and anything interfacing to C or hardware that/software that uses C style string interface (its difficult to send a C++ style string to/from a simple device, eg a NMEA gps spewer would be a mess trying to send that to you in c++)
but such code would not have tried to use std::min for the C-strings unless the code is not only old but borked up and bug ridden.
Back when times were simpler: we had a way to do this, and didn't need a redundant one. Today a common interface is more expected and having special snowflake stuff is frowned upon. Most of the code I ever wrote or used that had C style strings used arrays, never automatic constant pointers, as you can work with an array much more easily -- the const frequently was in the way.
you have everything you need though to make it happen cleanly in modern code. The string class is and can export a C-style string if you need one, and it can accept one in during construction, assignment, and the + operator and possibly other ways that I haven't worried about. So you can use min and still get a C string out if that is needed. There are only a tiny number of things that don't work well with the C++ tools and are a little better in C. I can only think of two of them, and believe me when I say it, I am one of the worst of the 'holdouts' of pre C++98 you are likely to meet. (Goes hand in hand with redundant ways to do stuff + set in my ways, but I have tried hard this last decade to overcome it).
what two? It annoys me that strstr is effectively a boolean and find() is not. And it annoys me that you can't as easily do in place destructive parsing (eg, move the pointer and zero out the end of lines for an example) of input. Minor things that there are other ways to get to the same place, but not as cleanly for either one: find requires an obnoxious constant (::nopos) and destructive parsing can be emulated with streams somewhat, though it is unfriendly about it. I am also not sure that c++ has a great strtok replacement, but that is a lot like the destructive parsing, same idea, and similar ways around it, just not quite the same.