Debian Codegraph @

sigc++/adaptors/bind_return.h

raw symbols SCIP
1 /*
2 * Copyright 2003 - 2016, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 #ifndef SIGC_ADAPTORS_BIND_RETURN_H
20 #define SIGC_ADAPTORS_BIND_RETURN_Hcxx . . $ `sigc++/adaptors/bind_return.h:20:9`!
21 #include <sigc++/adaptors/adapts.h>cxx . . $ `<file>/sigc++/adaptors/adapts.h`/
22 #include <sigc++/adaptors/bound_argument.h>cxx . . $ `<file>/sigc++/adaptors/bound_argument.h`/
23
24 namespace sigccxx . . $ sigc/
25 {
26
27 /** Adaptor that fixes the return value of the wrapped functor.
28 * Use the convenience function sigc::bind_return() to create an instance of
29 * sigc::bind_return_functor.
30 *
31 * The following template arguments are used:
32 * - @e T_return Type of the fixed return value.
33 * - @e T_functor Type of the functor to wrap.
34 *
35 * @ingroup bind
36 */
37 template<typename T_return, typename T_functor>
38 struct bind_return_functorcxx . . $ sigc/bind_return_functor# : public adaptscxx . . $ sigc/adapts#<T_functor>
39 {
40 /** Invokes the wrapped functor dropping its return value.
41 * @return The fixed return value.
42 */
43 typename unwrap_referencecxx . . $ sigc/unwrap_reference#<T_return>::type operatorcxx . . $ sigc/bind_return_functor#`operator()`(c32b693fc330c3dd).()();
44
45 /** Invokes the wrapped functor passing on the arguments.
46 * @param a Arguments to be passed on to the functor.
47 * @return The fixed return value.
48 */
49 template<typename... T_arg>
50 inline typename unwrap_referencecxx . . $ sigc/unwrap_reference#<T_return>::type operatorcxx . . $ sigc/bind_return_functor#`operator()`(8955a0838dcbef0d).()(T_arg... a)
51 {
52 stdcxx . . $ std/::invokecxx . . $ std/invoke(2acc70346a3bed67).(this->functor_cxx . . $ sigc/adapts#functor_., a...);
53 return ret_value_cxx . . $ sigc/bind_return_functor#ret_value_..invokecxx . . $ sigc/bound_argument#invoke(19b2b6f17af048b).();
54 }
55
56 /** Constructs a bind_return_functor object that fixes the return value to @p ret_value.
57 * @param functor Functor to invoke from operator()().
58 * @param ret_value Value to return from operator()().
59 */
60 bind_return_functorcxx . . $ sigc/bind_return_functor#`bind_return_functor<T_return, T_functor>`(1f3624aa09ba2e98).(type_trait_take_tcxx . . $ sigc/type_trait_take_t#<T_functor> functor, type_trait_take_tcxx . . $ sigc/type_trait_take_t#<T_return> ret_value)
61 : adaptscxx . . $ sigc/adapts#<T_functor>(functor), ret_value_cxx . . $ sigc/bind_return_functor#ret_value_.(ret_value)
62 {
63 }
64
65 /// The fixed return value.
66 bound_argumentcxx . . $ sigc/bound_argument#<T_return> ret_value_cxx . . $ sigc/bind_return_functor#ret_value_.; // public, so that visit_each() can access it
67 };
68
69 template<typename T_return, typename T_functor>
70 typename unwrap_referencecxx . . $ sigc/unwrap_reference#<T_return>::type
71 bind_return_functorcxx . . $ sigc/bind_return_functor#<T_return, T_functor>::operatorcxx . . $ sigc/bind_return_functor#`operator()`(c32b693fc330c3dd).()()
72 {
73 stdcxx . . $ std/::invokecxx . . $ std/invoke(2acc70346a3bed67).(this->functor_cxx . . $ sigc/adapts#functor_.);
74 return ret_value_cxx . . $ sigc/bind_return_functor#ret_value_..invokecxx . . $ sigc/bound_argument#invoke(19b2b6f17af048b).();
75 }
76
77 #ifndef DOXYGEN_SHOULD_SKIP_THIS
78 // template specialization of visitor<>::do_visit_each<>(action, functor):
79 /** Performs a functor on each of the targets of a functor.
80 * The function overload for sigc::bind_return_functor performs a functor on the
81 * functor and on the object instance stored in the sigc::bind_return_functor object.
82 *
83 * @ingroup bind
84 */
85 template<typename T_return, typename T_functor>
86 struct visitorcxx . . $ sigc/visitor#<bind_return_functorcxx . . $ sigc/bind_return_functor#<T_return, T_functor>>
87 {
88 template<typename T_action>
89 static void do_visit_eachcxx . . $ sigc/visitor#do_visit_each(e5a1145153785636).(const T_action& action,
90 const bind_return_functorcxx . . $ sigc/bind_return_functor#<T_return, T_functor>& target)
91 {
92 sigccxx . . $ sigc/::visit_eachcxx . . $ sigc/visit_each(13c11f7bd0e7e3d2).(action, target.ret_value_cxx . . $ sigc/bind_return_functor#ret_value_.);
93 sigccxx . . $ sigc/::visit_eachcxx . . $ sigc/visit_each(13c11f7bd0e7e3d2).(action, target.functor_cxx . . $ sigc/adapts#functor_.);
94 }
95 };
96 #endif // DOXYGEN_SHOULD_SKIP_THIS
97
98 /** Creates an adaptor of type sigc::bind_return_functor which fixes the return value of the passed
99 * functor to the passed argument.
100 *
101 * @param functor Functor that should be wrapped.
102 * @param ret_value Argument to fix the return value of @e functor to.
103 * @return Adaptor that executes @e functor on invocation and returns @e ret_value.
104 *
105 * @ingroup bind
106 */
107 template<typename T_return, typename T_functor>
108 inline bind_return_functorcxx . . $ sigc/bind_return_functor#<T_return, T_functor>
109 bind_returncxx . . $ sigc/bind_return(f6034cb9d136eeff).(const T_functor& functor, T_return ret_value)
110 {
111 return bind_return_functorcxx . . $ sigc/bind_return_functor#<T_return, T_functor>(functor, ret_value);
112 }
113
114 } /* namespace sigc */
115 #endif /* SIGC_ADAPTORS_BIND_RETURN_H */