-2

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

codeworks
  • 149
  • 1
  • 15
  • 5
    Peoble tell you nonsense or you didn't get right what they were saying. – πάντα ῥεῖ Sep 29 '16 at 09:20
  • Both STL and TR1 are library *specifications*, respectively from 1994 and 2005. They're not implementations. Anyone can implement anything they like for any platform. Why are we talking about this ancient, dead stuff though? The C++ standard library contains many useful aspects of both the STL and the TR1, and actual, usable implementations ship with all contemporary C++ compilers. – Kerrek SB Sep 29 '16 at 09:22

1 Answers1

1

No, the STL ( 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.

Pete Kirkham
  • 48,893
  • 5
  • 92
  • 171
  • Can you give an example to a STL usage that requires the compiler to use an intristic function? I'm sure there are, I just can't come up with one. – user3104201 Sep 29 '16 at 11:31
  • @user3104201 Other than the one above, no. – Pete Kirkham Sep 29 '16 at 11:56
  • You can implement atomic operations using mutexes (very inefficiently). std::is_pod is not possible to accurately implement without compiler support (it is safe to assume that e.g. no type is a POD, but it's again inefficient.). – n. m. could be an AI Sep 29 '16 at 12:20
  • 1
    @n.m. - you're right that you can implement atomic operations using mutexes, but an important goal of atomics is to be lock-free, and an implementation with mutexes is not lock-free. So an implementation with mutexes is formally conforming, but useless in practice. – Pete Becker Sep 29 '16 at 13:24