1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/Function.h
12 #ifndef ZYPP_BASE_FUNCTION_H
13 #define ZYPP_BASE_FUNCTION_H
15 #include <boost/function.hpp>
16 #define BOOST_BIND_GLOBAL_PLACEHOLDERS
17 #include <boost/bind.hpp>
18 #include <boost/ref.hpp>
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
24 /* http://www.boost.org/doc/html/function.html
26 The Boost.Function library contains a family of class templates
27 that are function object wrappers. The notion is similar to a
28 generalized callback. It shares features with function pointers
29 in that both define a call interface (e.g., a function taking
30 two integer arguments and returning a floating-point value)
31 through which some implementation can be called, and the
32 implementation that is invoked may change throughout the
33 course of the program.
35 Generally, any place in which a function pointer would be used
36 to defer a call or make a callback, Boost.Function can be used
37 instead to allow the user greater flexibility in the implementation
38 of the target. Targets can be any 'compatible' function object
39 (or function pointer), meaning that the arguments to the interface
40 designated by Boost.Function can be converted to the arguments of
41 the target function object.
43 using boost::function;
45 /* http://www.boost.org/libs/bind/bind.html
47 boost::bind is a generalization of the standard functions std::bind1st
48 and std::bind2nd. It supports arbitrary function objects, functions,
49 function pointers, and member function pointers, and is able to bind
50 any argument to a specific value or route input arguments into arbitrary
51 positions. bind does not place any requirements on the function object;
52 in particular, it does not need the result_type, first_argument_type and
53 second_argument_type standard typedefs.
57 /* http://www.boost.org/doc/html/ref.html
59 The Ref library is a small library that is useful for passing references
60 to function templates (algorithms) that would usually take copies of their
61 arguments. It defines the class template boost::reference_wrapper<T>, the
62 two functions boost::ref and boost::cref that return instances of
63 boost::reference_wrapper<T>, and the two traits classes
64 boost::is_reference_wrapper<T> and boost::unwrap_reference<T>.
66 The purpose of boost::reference_wrapper<T> is to contain a reference to an
67 object of type T. It is primarily used to "feed" references to function
68 templates (algorithms) that take their parameter by value.
70 To support this usage, boost::reference_wrapper<T> provides an implicit
71 conversion to T&. This usually allows the function templates to work on
72 references unmodified.
76 /////////////////////////////////////////////////////////////////
78 ///////////////////////////////////////////////////////////////////
79 #endif // ZYPP_BASE_FUNCTION_H