Reading Notes Objective c ++ Item 55 familiarize yourself with Boost and pull tiveboost

Source: Internet
Author: User

Reading Notes Objective c ++ Item 55 familiarize yourself with Boost and pull tiveboost

Are you looking for a set of high-quality, open-source libraries unrelated to platforms and compilers? Let's take a look at Boost. Want to join a group of ambitious, talented C ++ programmers who are working on the highest level of library design and implementation? Let's take a look at Boost. What will C ++ look like in the future? Let's take a look at Boost.

Boost is a group of C ++ developers and a set of C ++ libraries for free download. The URL is a http://boost.org.

1. Two advantages of Boost

Of course, there are many C ++ organizations and websites, but two aspects of Boost are not comparable to those of other organizations. First, it has a close relationship with the C ++ labeling committee and has an influence on the C ++ Standards Committee. Boost is created by members of the C ++ Standards Committee, so there is a large overlap between Boost and Committee members. In addition, one of the goals of Boost is to provide an experimental site for the ability to add standard C ++ features. One result of this relationship is that TR1 is introduced to 14 new libraries in C ++, with more than 2/3 of libraries being Boost-based.

2. Boost library Indexing Process

The second special feature of Boost is the process of receiving libraries. It is based on peer reviews. If you want to contribute a library to Boost, you first send an email to Boost developers, ask them to evaluate the importance of the library, and then begin a preliminary review of your work. This starts a cyclical process. The website will summarize it as "discussion, refinement, and re-release. Repeat this process until the Committee is satisfied ."

Finally, you decide that your library is ready for normal submission. The review manager confirms that your library meets the minimum Boost needs. For example, it must be compiled on at least two compilers (to ensure portability), and you must also ensure that this library can be used under an acceptable license (for example, the library must be free of charge for commercial and non-commercial use .) Then the Boost committee will be able to obtain the library you submitted and they will perform an official review. During the review, volunteers will carefully check your library materials (such as source code, design documents, instructions for use) and will consider the following:

  • How well is the design and implementation?
  • Can it be transplanted in different compilers and operating systems?
  • Is the library useful to the audience, that is, the people who use this library to handle problems?
  • Is the document clear, complete, and accurate?

These comments are sent to the Boost email list, so reviewers and others can see them and provide feedback on others' comments. At the end of the review, the Review Manager determines whether your library is accepted, conditional acceptance, or rejected.

Peer reviews can exclude poor libraries and help library authors to design, implement, and write documents on industry-intensive and cross-platform libraries. Many libraries require more than one official review before being declared as valuable and accepted.

Boost contains a large number of libraries, more of which are added based on your contributions. Some libraries are also removed from time to time because these functions are replaced by updated libraries, which provide better functions or better design (for example, more flexible or more efficient .)

3. Large and small Boost Libraries

The Boost library is very different in size and range. One extreme is that the Library requires only a few lines of code in concept (but longer code is required if it supports error handling and increased portability .) There is a library called Conversion that provides safer or more convenient cast operations. For example, if its numeric_cast function is converted from a numeric type to another numeric type, leading to memory overflow or similar problems, an exception will be thrown; lexical_cast converts any type that supports operator <to string, which is very helpful for diagnosis and log recording. The other extreme is that the Library provides a wide range of features that are used throughout the book to introduce them. Such libraries include Boost Graph Library (supporting programming using any chart structure) and Boost MPL Library ("metabase ").

4. Boost Library Classification

The Boost library processes a series of topics, which are divided into several categories. These types include:

  • String and text processing, including type-safe formatting, regular expressions (which is the basis of similar functions provided in TR1), tokenizing, and parsing.
  • Containers, including fixed-size arrays, have an interface similar to STL (see Item 54), bitset with variable capacity, and multi-dimensional arrays.
  • Function objects and advanced programming, including libraries that are used as the basis for functions in TR1. An interesting library is the Lambda library, which makes it very easy to create function objects. You are not even likely to realize what you are doing:

 1 using namespace boost::lambda;       // make boost::lambda 2 // functionality visible 3  4 std::vector<int> v; 5 ... 6 std::for_each(v.begin(), v.end(),         // for each element x in 7  8  9 std::cout << _1 * 2 + 10 << "\n"); // v, print x*2+10;10 // “_1” is the Lambda11 // library’s placeholder12 // for the current element

 

  • Generic programming involves a large number of traits classes. (See Item47)
  • Template metaprogramming (see Item 48), including libraries provided for assertions during compilation, and Boost MPL libraries. MPL supports the data structure of entities like STL during compilation, such as types:

1 // create a list-like compile-time container of three types (float,2 // double, and long double) and call the container “floats”3 typedef boost::mpl::list<float, double, long double> floats;4 // create a new compile-time list of types consisting of the types in5 // “floats” plus “int” inserted at the front; call the new container “types”6 typedef boost::mpl::push_front<floats, int>::type types;

 

 

This type of container (well known as typelist, although they can also be based on a mpl: vector or mpl: list) opens the door for a series of powerful and important TMP applications.

  • Mathematics and numbers, including libraries provided for rational numbers, octal elements and semicolons, calculation of the maximum common divisor and least common multiple, and random numbers (although this is another database that affects related functions in TR1 .)
  • Correctness and testing, including the Library (Item 41) provided for the formal implicit template interface and the library that makes the test easier.
  • Data structures, including libraries for type-safe union, and tuple libraries that implement the corresponding functions in TR1.
  • Memory, including Pool libraries (see Item50) for high-performance fixed-size memory splitters; smart pointers for some columns (Item13), including but not limited to smart pointers in tr1. This kind of non-TR1 smart pointer is scoped_array, a smart pointer for dynamically allocated arrays like auto_ptr; Item44 provides an instance.
  • Miscellaneous, including databases for CRC verification, databases for date and time operations, and databases moved on the file system.

Remember, this is only part of the Boost library. Not all of them are listed.

The libraries provided by Boost can do many things, but cannot do everything. For example, there is no library for GUI development or a library for communicating with the database. At least not now. But when you read this book, you may have it. The only way to understand them is to verify. I suggest you do it now: http://boost.org. Even if you don't find what you want, you can certainly find something interesting.

5. Summary
  • Boost is a community and website that provides developers with free, open-source, and peer-reviewed C ++ libraries. Boost has an influence on the C ++ standard.
  • Boost provides many implementations of the TR1 component, but also provides many other libraries.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.