This question already has answers here:
What's the difference between "STL" and "C++ Standard Library"?
(7 answers)
Closed 8 years ago.
Recently I have read an article that saying STL was developed by Alexander Stepanov prior to standardize the C++ and, It was a library at that time, like boost is nowadays. So few questions came in to my mind.
Can we download and use STL same like boost nowadays
Did STL included in to C++ standard? If that
What are things of STL, not included to stdlib,
What are the thing not from STL, but in stdlib
Did STL disappeared after C++ standardize
Can we say "There is no STL,But only Standard Library in C++"
yes - you can get it from SGI here, though god only knows if it'll compile on the latest compilers, or a more recently maintained version called STLport here
there are differences, for example the SGI STL has a bit_vector, though whether that was introduced before or after versions of most of the STL elements were Standardised I can't remember; while the Standard library includes the whole iostreams facility which was never part of the STL
obviously not, though after the available compiler-shipped implementations of the Standard got increasingly reliable there's been no reason to pick up a non-Standard version for new development; some old code doubtless still uses the STL (and lots of other similar non-Standard libraries)
as much as you can say "there's no boost in C++"... it's not part of the Standard
"But only Stranded Library in C++" - was that intentional? ;-)
This question already has answers here:
Is it smart to replace boost::thread and boost::mutex with c++11 equivalents?
(7 answers)
Closed 9 years ago.
What are the advantages/disadvantages of using the C++11 multithreading classes versus the ones found in Boost? I will only be using Linux so I do not require portability. Is there a lack of features in one of the libraries? Any known limitations? Better syntax?
Standard threads have the advantage of being standardised, therefore portable to any compliant implementation.
The Boost thread library is more or less identical; the standard library was based on that library, and there has been an effort to make Boost a conformant implementation of the standard. It has a few extensions which might be useful, including:
join with timeout
thread interruption
thread groups
extra lock types
In general, boost classes are only wrappers around functions/objects that exist in given OS. Their main advantage is that boost contains versions written for most operating systems, hence the wrapper provides portability the original functions/objects sometimes do not.
If there is nothing else your need from boost I would strongly suggest using standard C++11 threads.
Reasons:
boost will not provide more than the system allows for
your code will not have any wrapper overhead (however small it may be)
boost support for c++11 threads is a new feature and I would fear that it could introduce some errors in the boosts' implementation
you will not have to rely on boost libraries and will save yourself time compiling and linking them, etc.
you will not have to update boost, because you will not be using it
Of course, boost has some pros also:
many people know boost and the code will (possibly) be easier to read
if you decide you need to port the code you may have an easier time (though C++11 is standard, so somewhere down the line all compilers will implement it)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm reading Boost array documentation and I see this line :
If you are using C++11, you should consider using std::array instead of boost::array
I was under the impression that Boost, for its major libs, was always preferable to standard lib because :
boost will never perform worse than the standard lib
boost may provide more features
boost is at last of equal quality than standard lib (people writing the C++ standard are active boost developpers/supervisors)
major boost features end up in the standard lib a few years later
So am I right to prefer boost over stdlib ?
If not / more complicated, which of my assumptions are to be corrected ?
I think you should use standard lib when available because... it's standard and comes with the compiler. Besides, if you use boost you need an annoying external dependency.
So, my advice is: use std when possible. If you're writing portable code, that must also be compiled with old compilers, you can consider to use your own namespace (e.g.: cxx0x) that embeds std or boost namespace according to the compiler you're using (this is called namespace alias):
#ifdef COMPILER_HAS_CXX0X
#include <memory>
namespace cxx0x = std;
#else
#include <boost/shared_ptr.hpp>
namespace cxx0x = boost;
#endif
...
cxx0x::shared_ptr<MyClass> = ...
Taken from the Boost people themselves:
Why should an organization use Boost?
In a word, Productivity. Use of
high-quality libraries like Boost
speeds initial development, results in
fewer bugs, reduces
reinvention-of-the-wheel, and cuts
long-term maintenance costs. And since
Boost libraries tend to become de
facto or de jure standards, many
programmers are already familiar with
them.
Ten of the Boost libraries are
included in the C++ Standard Library's
TR1, and so are slated for later full
standardization. More Boost libraries
are in the pipeline for TR2. Using
Boost libraries gives an organization
a head-start in adopting new
technologies.
Many organization already use programs
implemented with Boost, like Adobe
Acrobat Reader 7.0.
From my own experience I prefer to use boost for now. Maybe it's historical, but I found the STD attempts in TR1 that came with VC2008 had too many bugs, in spite of PJ Plauger's best efforts, he couldn't reproduce the quality of the peer-reviewed and checked code of boost that had gone through quite a bit of history.
Unless they can actually take the boost code and use it in STD, why would they reproduce it better? Of course sometimes they might, and really they should work together on it rather than against each other.
One thing I do now though is declare an alias namespace, usually called spns thus:
namespace spns = boost;
after which I can use spns::shared_ptr throughout my code (spns stands for "shared pointer namespace") and if we ever change to std later it will be easy to go to one place and edit just that line and the include.
When it comes to C++11, there are major changes to the Standard and boost's code is C++03. So now the tables are likely to turn for certain parts of the library. I reckon some of boost's fine libraries will become almost obsolete for C++11, e.g. nobody will use boost::lambda anymore, they will just use the new language syntax for a lambda.
So yes, when you move to C++11, it may be time to abandon parts of the boost library and use the new versions.
The trend that I have seen in open source software developed against C++11 is to move API-compatible (subset of) features from STD to boost - because boost is available for non-C++11-compatible compilers where the std features are (obviously) not.
Good example of this is mosh.
For API-compatible features, it's simply a matter of switching namespaces around. In fact, no reason not to make it a configuration option, if you can.
Sidebar: if you're linking against the latest version of non-header-only boost libraries, be forewarned that certain features are no longer available unless boost was compiled with -std=c++11. I ran into this recently with certain functions in the boost::filesystem API.
If something can be standard let it be standard.
If something cannot, use the solution more standard as possible (and BOOST is designed for that)
Many standard library feature are taken from boost, that continue to exist to support application that where deployed when those feature where not yet been standardized.
Using boost for standardized feature is in fact a "look backward". Sometime necessary (may be the standard library specific implementation does not include all what is required ... it is typical to see boost::thread instead of std::thread on windows because of a std implementation not yet been ported by some compilers) but I would not make it a rule.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Do I need to protect read access to an STL container in a multithreading environment?
I am using the C++ standard library which comes with (Linux) GCC or (Windows) VC.
Can anyone please say clearly whether or not this library is thread safe?
"Thread safe" is not a clearly-defined boolean property of a library. Some things can be done concurrently and others cannot.
Almost certainly if you were to ask a more detailed question specifying what it is you want to do, the answer would be "no, it is not thread-safe". But only almost.
If by "thread-safe" you mean something like the difference between Vector and ArrayList in Java, then C++ standard containers are non-thread-safe.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
C Analog To STL
Is there something like STL for C.
You can have a look at the glib, which provides lots of interesting features
well there is the C library of course :) but I do not see the use of templates for C
There's not really anything quite like the STL; but there are a lot of libraries. glib has been mentioned, but usually it's not always useable together with whatever libraries you are using for actually achieving what you want to do.