简体   繁体   中英

Does C++ STL or TR1(not boost::tr1) work only on Windows?

I was thinking STL was a standard implementation, though TR1 may not be. But does the platform matter? I was thinking it would work on Windows/Linux/Unix/Mac. I have people saying it wont work on anything other than Windows.

Please let me know.

-TIA

No, theSTL ( not to be confused with the C++ standard library ) was developed by Alexander Stepanov when working for HP and Silicon Graphics. Much of the STL later was included into the C++ standard library, hence sometimes the STL and the templated containers in the C++ standard library are confused.

The second STL implementation (SGI) was designed to work with any standard complient C++ compiler, though IIRC not the early Microsoft 'C++' compilers due to lack of required features. (I seem to recall trying to play with it in the late 90s). The C++ standard library now requires some compiler intrinsics so there is no 'standard implementation' possible. (IIRC these are for atomic operations, but edit or comment if you know better)

So the implementation of the C++ standard library which ships with Visual Studio will only work with 'Windows'*, and probably only with Microsoft's C++ compiler. Other implementations will work with other compilers and on other platforms.

*Visual studio C++ can cross compile to other variants of Windows, so a version of the standard library for Windows 10 x64 will not work on Windows 7 ARM embedded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM