Daniel Eder
Daniel Eder

Reputation: 90

Is C++ std::string platform independent?

I am wondering if the std::string of C++ is platform independent meaning that it is available for all compiler implementations.

Background is that I am working with some pretty old legacy code that does not make use of any std::string (of std::something) stuff and that makes it troublesome to work with. It is compiled on Windows and Unix systems including somewhat more exotic platforms like AIX, zLinux, Solaris and HPUX.

It would make life much easier if I could just use the std library but I don't know if it will work on all of those platforms. Any experiences with things like this?

Upvotes: 0

Views: 577

Answers (2)

Marco A.
Marco A.

Reputation: 43662

std::string is part of the C++ standard (cfr. [string.classes]) so it is available with every C++-standard conforming implementation.

Be aware though that something might have changed from a major C++ version to another one, e.g. std::string::front (since C++11). If you want your codebase to be portable and consistent you should keep this in mind and also check for the highest available (for whatever reason, stability, policies, backward compatibility, etc..) C++ version you can target.

Upvotes: 2

TartanLlama
TartanLlama

Reputation: 65610

std::string is part of the standard library and should be available on any conforming implementation.

Upvotes: 2

Related Questions