Function Objects and Higher-Order Programming


Boost.Bind

Bind is a generalization of the Standard Library binders, bind1st and bind2nd. The library supports binding arguments to anything that behaves like a functionfunction pointers, function objects, and member function pointers with a uniform syntax. It also enables functional composition by means of nested binders. This library does not have all of the requirements that are imposed by the Standard Library binders, most notably that there is often no need to provide the typedefs result_type, first_argument_type, and second_argument_type for your classes. This library also makes it unnecessary to use the adaptors ptr_fun, mem_fun, and mem_fun_ref. The Bind library is thoroughly covered in "Library 9: Bind 9." It's an important and very useful addition to the C++ Standard Library. Bind is typically used with the Standard Library algorithms, and is often used together with Boost.Function, yielding a powerful tool for storing arbitrary functions and function objects for subsequent invocation. Bind has been accepted for the upcoming Library Technical Report.

The author of Bind is Peter Dimov.

Boost.Function

The Function library implements a generalized callback mechanism. It provides for the storage and subsequent invocation of function pointers, function objects, and member function pointers. Of course, it works with binder libraries such as Boost.Bind and Boost.Lambda, which greatly increases the number of use cases for callbacks (including stateful callback functions). The library is covered in detail in "Library 11: Function 11." Function is typically used where a function pointer would otherwise be employed to provide callbacks. Examples of usage are in signal/slot implementations, separation of GUIs from business logic, and storage of heterogeneous function-like types in Standard Library containers. Function has been accepted for the upcoming Library Technical Report.

The author of Function is Douglas Gregor.

Boost.Functional

The Functional library provides enhanced versions of the adapters in the C++ Standard Library. The major advantage is that it helps solve the problem with references to references (which are illegal) that arise when using the Standard Library binders with functions taking one or more arguments by reference. Functional also obviates the use of ptr_fun for using function pointers with the Standard Library algorithms.

The author of Functional is Mark Rodgers.

Boost.Lambda

Lambda provides lambda expressionsunnamed functionsfor C++. Especially useful when using the Standard Library algorithms, Lambda allows functions to be created at the call site, which avoids the creation of many small function objects. Using lambdas means writing less code, and writing it in the location where it's to be used, which is much clearer and maintainable than scattering function objects around the code base. "Library 10: Lambda 10" covers this library in detail.

The authors of Lambda are Jaakko Järvi and Gary Powell.

Boost.Ref

Many function templates, including a large number from the Standard C++ Library, take their arguments by value, which is sometimes problematic. It may be expensive or impossible to copy an object, or the state may be tied to a particular instance, so copying is unwanted. In these situations, one needs a way to pass by reference rather than by value. Ref wraps a reference to an object and turns it into an object that may be copied. This permits calling functions taking their arguments by value with a reference. Ref has been accepted for the upcoming Library Technical Report.

The authors of Ref are Jaakko Järvi, Peter Dimov, Douglas Gregor, and David Abrahams.

Boost.Signals

Signals and slots systems, based on a pattern also known as publisher-subscriber and observer, are important tools for managing events in a system with a minimum of dependencies. Few large applications get by without some variation of this powerful design pattern, though typically they use proprietary implementations. Signals provides a proven and efficient means to decouple the emission of signals (events/subjects) from the slots (subscribers/observers) that need notification of those signals.

The author of Signals is Douglas Gregor.



    Beyond the C++ Standard Library(c) An Introduction to Boost
    Beyond the C++ Standard Library: An Introduction to Boost
    ISBN: 0321133544
    EAN: 2147483647
    Year: 2006
    Pages: 125

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net