Difference between STLPort and SGI STL

Recently, the following problem has buzzed me. The STL class std :: string causes crashes and memory corruption on multiprocessor machines when using VC6.

I plan to use alternative STL libraries instead of those provided by VC6.

I came across two libraries: STLPort and SGI STL

I was wondering what is the difference between 2. Which one should I use? Which one can guarantee the flow safety?

Thanks.

+4
source share
3 answers

Here is the story of the relationship between STLPort and SGI STL

http://stlport.sourceforge.net/History.shtml

+3
source

Just a tip.
When we made the transition from the VC6 standard to STLPort stl, the main difference that I noticed was the erase method for collections.

In VC6 erase , the next valid iterator is returned.
In STLPort, this simply is not.

So, for these cases, you need to write something like this:

 for(iterator it = begin; it != end; ) { iterator next = it; ++next; if ( cond ) collection.erase(it); } 

Good luck

+4
source

I don't know much about STLPort, but looking at their page describing thread safety , they provide nothing more than an SGI implementation. They link to the SGI page. STLPort seems to be mostly useful for platform portability.

STL containers are unsafe for writing at once, but can be read by multiple threads. If you are going to do parallel recordings, you will need to provide your own mutex (for example, the one provided by boost ).

The SGI website has a full explanation of SGI thread safety policies .

It looks like VC6 was shipped with a bad library that had an error in counting line references with copy to write.

0
source

Source: https://habr.com/ru/post/1307875/


All Articles