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