/usr/include/sigc++-2.0/sigc++/adaptors/bound_argument.h is in libsigc++-2.0-dev 2.10.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | /*
* Copyright 2005, The libsigc++ Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _SIGC_BOUND_ARGUMENT_H_
#define _SIGC_BOUND_ARGUMENT_H_
#include <sigc++/limit_reference.h>
#include <sigc++/reference_wrapper.h>
namespace sigc {
/** A bound_argument<Foo> object stores a bound (for instance, with sigc::bind(), or sigc::bind_return()) argument.
*
* If Foo is a wrapped reference to a class Bar (reference_wrapper<Bar>) then this
* object is implemented on top of a limit_reference. When the slot is
* invoked, the limit_reference::invoke() method provides the argument (a Bar&).
* When the slot is visited (e.g. visit_each<>()), we simply visit the limit_reference,
* which will visit the derived type, or a sigc::trackable base if necessary.
*
* Likewise, If Foo is a wrapped const reference to a class Bar (const_reference_wrapper<Bar>)
* then this object is implemented on top of a const_limit_reference.
*
* If Foo is something else (such as an argument that is bound by value) bound_argument just
* stores a cop of that value, and both invoke() and visit() simply return it.
*
* This object is used by the bind_functor<> and bind_return_functor<> objects,
* depending on whether the argument is bound as a parameter or as a return value.
*
* The general template implementation is used for parameters that are passed by value.
* @e T_type The type of the bound argument.
*/
template <class T_type>
class bound_argument
{
public:
/** Constructor.
* @param _A_argument The argument to bind.
*/
bound_argument(const T_type& _A_argument)
: visited_(_A_argument)
{}
/** Retrieve the entity to visit in visit_each().
* @return The bound argument.
*/
inline const T_type& visit() const
{ return visited_; }
/** Retrieve the entity to pass to the bound functor or return.
* @return The bound argument.
*/
inline T_type& invoke()
{ return visited_; }
private:
/** The value of the argument.
*/
T_type visited_;
};
#ifndef SIGCXX_DISABLE_DEPRECATED
//Template specialization:
/** bound_argument object for a bound argument that is passed by bind() or
* returned by bind_return() by reference, specialized for reference_wrapper<> types.
* @e T_wrapped The type of the bound argument.
*/
template <class T_wrapped>
class bound_argument< reference_wrapper<T_wrapped> >
{
public:
/** Constructor.
* @param _A_argument The argument to bind.
*/
bound_argument(const reference_wrapper<T_wrapped>& _A_argument)
: visited_(unwrap(_A_argument))
{}
/** Retrieve the entity to visit in visit_each().
* @return The limited_reference to the bound argument.
*/
inline const limit_reference<T_wrapped>& visit() const
{ return visited_; }
/** Retrieve the entity to pass to the bound functor or return.
* @return The bound argument.
*/
inline T_wrapped& invoke()
{ return visited_.invoke(); }
private:
/** The limited_reference to the bound argument.
*/
limit_reference<T_wrapped> visited_;
};
/** bound_argument object for a bound argument that is passed by bind() or
* returned by bind_return() by const reference, specialized for const reference_wrapper<> types.
* - @e T_wrapped The type of the bound argument.
*/
template <class T_wrapped>
class bound_argument< const_reference_wrapper<T_wrapped> >
{
public:
/** Constructor.
* @param _A_argument The argument to bind.
*/
bound_argument(const const_reference_wrapper<T_wrapped>& _A_argument)
: visited_(unwrap(_A_argument))
{}
/** Retrieve the entity to visit in visit_each().
* @return The const_limited_reference to the bound argument.
*/
inline const const_limit_reference<T_wrapped>& visit() const
{ return visited_; }
/** Retrieve the entity to pass to the bound functor or return.
* @return The bound argument.
*/
inline const T_wrapped& invoke()
{ return visited_.invoke(); }
private:
/** The const_limited_reference to the bound argument.
*/
const_limit_reference<T_wrapped> visited_;
};
#endif // SIGCXX_DISABLE_DEPRECATED
//Template specialization:
/** bound_argument object for a bound argument that is passed by bind() or
* returned by bind_return() by reference, specialized for std::reference_wrapper<> types.
* @e T_wrapped The type of the bound argument.
*/
template <class T_wrapped>
class bound_argument< std::reference_wrapper<T_wrapped> >
{
public:
/** Constructor.
* @param _A_argument The argument to bind.
*/
bound_argument(const std::reference_wrapper<T_wrapped>& _A_argument)
: visited_(unwrap(_A_argument))
{}
/** Retrieve the entity to visit in visit_each().
* @return The limited_reference to the bound argument.
*/
inline const limit_reference<T_wrapped>& visit() const
{ return visited_; }
/** Retrieve the entity to pass to the bound functor or return.
* @return The bound argument.
*/
inline T_wrapped& invoke()
{ return visited_.invoke(); }
private:
/** The limited_reference to the bound argument.
*/
limit_reference<T_wrapped> visited_;
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/** Implementation of visitor<>::do_visit_each<>() specialized for the bound_argument class.
* Call visit_each() on the entity returned by the bound_argument's visit()
* method.
* @tparam T_type The type of bound_argument.
* @tparam T_action The type of functor to invoke.
* @param _A_action The functor to invoke.
* @param _A_argument The visited instance.
*/
template <class T_type>
struct visitor<bound_argument<T_type> >
{
template <class T_action>
static void do_visit_each(const T_action& _A_action,
const bound_argument<T_type>& _A_argument)
{
sigc::visit_each(_A_action, _A_argument.visit());
}
};
#endif // DOXYGEN_SHOULD_SKIP_THIS
} /* namespace sigc */
#endif /* _SIGC_BOUND_ARGUMENT_H_ */
|