Item 54:familiarize yourself with the standard library, including TR1.
The name C + + was put forward by Rick Mascitti in 1983, and C + + used the name "New C", "C with Classes". 1998 ISO/IEC 14882 released the first C + + standard, which is what we often talk about as a c++98. The following standards also include C++03,C++TR1,C++11,C++14. It is worth mentioning that the C++11 standard, which has been supported by the mainstream compilers. Contains the new functions of the core language, and extends the C + + standard library, incorporating most of the C + + TR1 libraries. Effective most of C + + Edition 3std::tr1
are available instd
Under direct access.
Let's review the contents of c++98:
- STL (Standard Template Library), including container iterators and algorithms.
- IOstream, supports standard IO, user-defined Io, and predefined objects:
cin
,cout
,cerr
,clog
。
- Internationalization support. such as
wchar_t
16-bit Unicode characters.
- digital processing. Added
complex
, valarray
and so on.
- abnormal results. Includes base class
exception
, subclass logic_error
, runtime_error
and so on.
- C89 's standard library. The C standard Library of 1989 was incorporated into the c++98.
Effective C + + Edition 3 mentions a lot of the concepts of TR1 (Technical Report 1):
- Smart pointer:
tr1::shared_ptr
, tr1::weak_ptr
, tr1::auto_ptr
, etc., see item 13.
tr1::function
: can represent a callable entity, which can be a function, function object, and so on, see item 35.
TR1::bind
: Bind a function to an object (that is, replace this
), see Item35.
- Hash table:
TR1::unordered_set
,TR1::unordered_multiset
,TR1::unordered_map
,TR1::unordered_multimap
。
- Regular expressions
- Tuples: There is already a template in the STL that
pair
contains two elements, with an unlimited number of elements presented in the TR1 TR1::tuple
.
TR1::array
: An array of STL styles.
TR1::mem_fn
: Provides a uniform way to fit a member function pointer.
TR1::reference_wrapper
: Makes a reference more like an object that can only store pointers and objects in a container.
- Random Number: C + +
rand
comes from the C89 standard, TR1 gives a better random number algorithm.
- Special mathematical functions: LaGrand day polynomial, Bessel function, elliptic integral and so on.
- C99 compatible Extensions: introduces a number of C99 features.
- Type characteristics (traits): A class template used to identify type information at compile time, see item 47.
TR1::result_of
: A template that is used to derive the return type of a function call.
boost is a community worth exploring, and 14 out of the TR1 10 are from the boost community. Boost provides a template library that requires only the include path, and the boost does not even require a build. Because the features in TR1 are basically in boost, you can tell your compiler to put tr1
as boost
:
namespace std { namespace tr1 = :: boost }
item 25 mentions that if you're in std
to add something privately will result in undefined behavior. But the code above is usually no problem in practice.
In short, the standard C + + library is made up of STL, iostream, localization, and C99. TR1 adds smart pointers, universal function pointers, hash containers, regular expressions, and 10 other components. TR1 is a standard, in order to use TR1 you need a TR1 implementation (implementation), Boost is a good TR1 implementation.
This address: http://harttle.com/2015/09/24/effective-cpp-54.html
Item 54: Familiarize yourself with the standard library, such as TR1