Go beyond C ++ standard library: boost library guide: boost library introduction-function objects and high-level programming

Source: Internet
Author: User
Function objects and High-Order programming (function objects and higher-order programming) boost. Bind

BIND is a generalization of the standard library binder (bind1st and bind2nd. This library supports binding any behavior similar to a function, function pointer, function object, or member function pointer using a unified syntax. It also supports functional composition ). This library does not need the prerequisites required by the standard library binder, the most obvious difference is that you do not need to provide Type Definitions about result_type, first_argument_type, and second_argument_type for your class in most cases ). With this library, there is no need to use ptr_fun, mem_fun, and mem_fun_ref adapters. "Library 9: BIND 9" provides a comprehensive introduction to the BIND library. This library is an important and useful supplement for the c ++ standard library. BIND is usually used together with the standard library algorithm, and is often used together with boost. function to generate a powerful tool to store arbitrary functions and function objects for subsequent calls. The BIND has been adopted by the upcoming standard library technical report.

The author of BIND is Peter DIMOV.

Boost. Function

The function library implements a general callback mechanism. It can be used to store function pointers, function objects, and member function pointers and then call them. Of course, it often needs to work with boost. bind and boost. the use of libraries such as Lambda can greatly improve the scope of use of callbacks (including callback functions related to their own States. This library is described in detail in "library 11: function 11. Generally, a function is used where the function pointer is required for callback. Examples of its usage include the implementation of signal/slot, the separation of guis from business logic, and how to store heterogeneous function-like types into standard library containers. Function has been adopted by the upcoming standard library technical report.

Function is written by Douglas Gregor.

Boost. Functional

The functional Library provides an enhanced version of the C ++ standard library adapter. The best thing about it is to solve the problem of using the standard library binder to bind one or more functions that reference parameters, (This is not legal ). In addition, when using function pointers and standard library algorithms through functional, ptr_fun is no longer necessary.

Functional is written by Mark Rodgers.

Boost. Lambda

The Lambda Library provides lambda expressions for C ++, that is, unnamed functions ). It is particularly useful when using standard library algorithms. Lambda Allows defining functions in the called place, which avoids creating many small function objects. Using lambda expressions means writing less code and writing where it is used, which is clearer and easier to maintain than function objects scattered in the Code body. "Library 10: Lambda 10" describes this library in detail.

Lambda was prepared by Jaakko järvi and Gary Powell.

Boost. Ref

Many function templates (including many function templates in the Standard C ++ Library) accept parameters by passing values. In some cases, this may cause problems. It is possible that copying an object is too costly or cannot be copied at all, or the object State is bound to a specific instance to copy the object. In these cases, we need a method to pass references instead of passing values. Ref overwrites a reference to an object and converts it to an object that may be copied. This allows you to call a function to accept parameters by referencing and passing values. Ref has been adopted by the upcoming standard library technical report.

The authors of ref are Jaakko järvi, Peter DIMOV, Douglas Gregor, and David Abrahams.

Boost. Signals

A system composed of signals and slots is based on this mode. This mode is also used as the publisher-subscriber mode or observer mode, they are very important tools for managing system events with minimal dependencies. Almost all large applications use a certain variant of this strong pattern, although they usually use dedicated implementations. The signals Library provides proven and efficient methods to separate the generation of signals (events/observed) from the signal observer to be notified (Subscriber/Observer.

Signals is written by Douglas Gregor.

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.