Ix. Miscellaneous Discussions

Source: Internet
Author: User

Article 53: Don't overlook compiler warnings

The compiler's author's understanding of some of the next possible errors must be better than those of us ordinary programmers, and if the compiler warns you that there may be some kind of situation that could cause some errors that you might not have thought of. So let's not ignore compiler warnings!

class Base{public:    virtual void f() const;};class Derive{public:    virtual void f();};

After this section is compiled, the compiler warns you:

warning:D::f() hides virtual B::f()

This warning tells you that the whole b::f () has been obscured, not just b::f () removing the Const.

If you think it's just hiding the const, it's a big mistake.

Author summary

Take a warning message from the compiler seriously. Strive for "no warning" honors at the highest (most stringent) warning level of your compiler.

Do not rely too much on the compiler's alarm capabilities, because different compilers do not have the same attitude towards things. Once ported to another compiler, the warning message you relied on might disappear.

Article 54: Familiarize yourself with the standard library of programs including TR1

TR1 stands for "Technical report 1".
Before summarizing TR1, take a look at what the main components of c++98 include in the C + + standard library:

    • Stl.
    • Iostream, covering user-defined buffering capabilities, internationalized Io, and predefined objects Cin,cout,cerr and clog.
    • International support , including multi-regional capabilities, such as wchar_t and wstring.
    • numeric processing. includes a complex template (complex) and a pure numeric array (Valarray).
    • Abnormal hierarchy System.
    • C89 Standard Program Library.

The following shows the TR1 component instances:

    • Smart pointers.
    • tr1::function. This object can represent any callable entity (callable, that is, any function or function objects). For example, we want to register a callback function that takes an int and returns a string, which we can write:

      void RegisterCallback (std::string (int));
      The use of tr1::function words, more flexible. * * We accept an int or any value that can be converted to int and return a string or anything that can be turned into a string:

      void RegisterCallback (std::tr1::function

    • Tr1::bind, this is also very important, the specific other blog will talk about.
    • Hash tables. Used to implement Set,multi_set,map,multi_map.
    • the regular expression .
    • tuples, which is the variable group. Tr1::tuple can hold any number of objects.
    • Tr1::array. is an STL array that supports the array of member functions begin and end, fixed in size, and not suitable for dynamic memory.
    • Tr1::reference_wrapper.
    • Random number Generation tool.
    • Mathematical Special functions. including Laguerre polynomial, Bessel function, complete elliptic integral and so on.
    • C99 compatible extensions.
    • Type traits.
    • tr1::result_of, is a template used to derive the return type of a function call.

Author summary

The main functions of the C + + standard library are composed of stl,iostream,locals and include the C99 standard library.

TR1 adds a smart pointer (shared_ptr), generalized function pointer (tr1::function), hash-based container, regular expression, and 10 additional components to support.

TR1 own knowledge a specification. To get the benefits of TR1, you need a physical, a good physical source is boost.

Article 55: Familiarize yourself with boost why should you be familiar with boost?

One is because it has a strong connection with the C + + Standards Committee: it was created by members of the Commission.

The second is that it accepts the process of the library procedure comparison specification:

(1) before sending a post, the boost developer will evaluate the importance of the library and initiate a preliminary review process.

(2) then start the "discussion, pondering, re-submission" cycle.

(3) Finally prepare the library, formally submitted. A review manager will come forward to confirm that your program meets the minimum boost requirements. For example, a minimum of two compilers is required to accommodate portability.

(4) Your submission is then formally entered into the boost community awaiting official review. During the period, volunteers will review the various materials in your library and consider issues such as the following:

    • How good is this design and implementation?
    • Can this code span the compiler and the operating system?
    • Is this library likely to be used by the target users it sets ———— that is the people who work in the area where the library is trying to solve the problem?
    • Is the document clear, complete, and accurate?
    • string and text processing. does the coverage have type safety and so on.
Author summary

Boost is a community and a website. Dedicated to free, open source, peer review of C + + library development. Boost plays a powerful role in the C + + standardization process.

Boost offers many TR1 component implementations, as well as many other library applications.

Ix. Miscellaneous Discussions

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.