/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h is in libsigc++-2.0-dev 2.10.0-1.
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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | // -*- c++ -*-
/* Do not edit! -- generated file */
#ifndef _SIGC_ADAPTORS_ADAPTOR_TRAIT_H_
#define _SIGC_ADAPTORS_ADAPTOR_TRAIT_H_
#include <sigc++config.h> //To get SIGC_TEMPLATE_KEYWORD_OPERATOR_OVERLOAD
#include <sigc++/visit_each.h>
#include <sigc++/functors/functor_trait.h>
#include <sigc++/functors/ptr_fun.h>
#include <sigc++/functors/mem_fun.h>
#include <sigc++/adaptors/deduce_result_type.h>
namespace sigc {
// Call either operator()<>() or sun_forte_workaround<>(),
// depending on the compiler:
#ifdef SIGC_GCC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
#define SIGC_WORKAROUND_OPERATOR_PARENTHESES template operator()
#define SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
#else
#ifdef SIGC_MSVC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
#define SIGC_WORKAROUND_OPERATOR_PARENTHESES operator()
#define SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
#else
#define SIGC_WORKAROUND_OPERATOR_PARENTHESES sun_forte_workaround
#endif
#endif
#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <class T_functor> struct adapts;
#endif
/** @defgroup adaptors Adaptors
* Adaptors are functors that alter the signature of a functor's
* operator()().
*
* The adaptor types libsigc++ provides
* are created with bind(), bind_return(), hide(), hide_return(),
* retype_return(), retype(), compose(), exception_catch(), track_obj()
* and group().
*
* You can easily derive your own adaptor type from sigc::adapts.
*/
/** Converts an arbitrary functor into an adaptor type.
* All adaptor types in libsigc++ have
* a <tt>template operator()</tt> member of every argument count
* they support. These functions in turn invoke a stored adaptor's
* <tt>template operator()</tt>, processing the arguments and return
* value in a characteristic manner. Explicit function template
* instantiation is used to pass type hints thus saving copy costs.
*
* adaptor_functor is a glue between adaptors and arbitrary functors
* that just passes on the arguments. You won't use this type directly.
*
* The template argument @e T_functor determines the type of stored
* functor.
*
* @ingroup adaptors
*/
template <class T_functor>
struct adaptor_functor : public adaptor_base
{
#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <class T_arg1=void, class T_arg2=void, class T_arg3=void, class T_arg4=void, class T_arg5=void, class T_arg6=void, class T_arg7=void>
struct deduce_result_type
{ typedef sigc::deduce_result_t<T_functor, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7> type; };
#endif
typedef typename functor_trait<T_functor>::result_type result_type;
/** Invokes the wrapped functor passing on the arguments.
* @return The return value of the functor invocation.
*/
result_type
operator()() const;
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
result_type sun_forte_workaround() const
{ return operator(); }
#endif
/** Invokes the wrapped functor passing on the arguments.
* @param _A_arg1 Argument to be passed on to the functor.
* @return The return value of the functor invocation.
*/
template <class T_arg1>
typename deduce_result_type<T_arg1>::type
operator()(T_arg1 _A_arg1) const
{ return functor_(_A_arg1); }
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
template <class T_arg1>
typename deduce_result_type<T_arg1>::type
sun_forte_workaround(T_arg1 _A_arg1) const
{ //Just calling operator() tries to copy the argument:
return functor_(_A_arg1);
}
#endif
/** Invokes the wrapped functor passing on the arguments.
* @param _A_arg1 Argument to be passed on to the functor.
* @param _A_arg2 Argument to be passed on to the functor.
* @return The return value of the functor invocation.
*/
template <class T_arg1, class T_arg2>
typename deduce_result_type<T_arg1, T_arg2>::type
operator()(T_arg1 _A_arg1, T_arg2 _A_arg2) const
{ return functor_(_A_arg1, _A_arg2); }
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
template <class T_arg1, class T_arg2>
typename deduce_result_type<T_arg1, T_arg2>::type
sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2) const
{ //Just calling operator() tries to copy the argument:
return functor_(_A_arg1, _A_arg2);
}
#endif
/** Invokes the wrapped functor passing on the arguments.
* @param _A_arg1 Argument to be passed on to the functor.
* @param _A_arg2 Argument to be passed on to the functor.
* @param _A_arg3 Argument to be passed on to the functor.
* @return The return value of the functor invocation.
*/
template <class T_arg1, class T_arg2, class T_arg3>
typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type
operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3) const
{ return functor_(_A_arg1, _A_arg2, _A_arg3); }
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
template <class T_arg1, class T_arg2, class T_arg3>
typename deduce_result_type<T_arg1, T_arg2, T_arg3>::type
sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3) const
{ //Just calling operator() tries to copy the argument:
return functor_(_A_arg1, _A_arg2, _A_arg3);
}
#endif
/** Invokes the wrapped functor passing on the arguments.
* @param _A_arg1 Argument to be passed on to the functor.
* @param _A_arg2 Argument to be passed on to the functor.
* @param _A_arg3 Argument to be passed on to the functor.
* @param _A_arg4 Argument to be passed on to the functor.
* @return The return value of the functor invocation.
*/
template <class T_arg1, class T_arg2, class T_arg3, class T_arg4>
typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type
operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4) const
{ return functor_(_A_arg1, _A_arg2, _A_arg3, _A_arg4); }
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
template <class T_arg1, class T_arg2, class T_arg3, class T_arg4>
typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4>::type
sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4) const
{ //Just calling operator() tries to copy the argument:
return functor_(_A_arg1, _A_arg2, _A_arg3, _A_arg4);
}
#endif
/** Invokes the wrapped functor passing on the arguments.
* @param _A_arg1 Argument to be passed on to the functor.
* @param _A_arg2 Argument to be passed on to the functor.
* @param _A_arg3 Argument to be passed on to the functor.
* @param _A_arg4 Argument to be passed on to the functor.
* @param _A_arg5 Argument to be passed on to the functor.
* @return The return value of the functor invocation.
*/
template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5>
typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type
operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5) const
{ return functor_(_A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5); }
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5>
typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::type
sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5) const
{ //Just calling operator() tries to copy the argument:
return functor_(_A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5);
}
#endif
/** Invokes the wrapped functor passing on the arguments.
* @param _A_arg1 Argument to be passed on to the functor.
* @param _A_arg2 Argument to be passed on to the functor.
* @param _A_arg3 Argument to be passed on to the functor.
* @param _A_arg4 Argument to be passed on to the functor.
* @param _A_arg5 Argument to be passed on to the functor.
* @param _A_arg6 Argument to be passed on to the functor.
* @return The return value of the functor invocation.
*/
template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6>
typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type
operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6) const
{ return functor_(_A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5, _A_arg6); }
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6>
typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::type
sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6) const
{ //Just calling operator() tries to copy the argument:
return functor_(_A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5, _A_arg6);
}
#endif
/** Invokes the wrapped functor passing on the arguments.
* @param _A_arg1 Argument to be passed on to the functor.
* @param _A_arg2 Argument to be passed on to the functor.
* @param _A_arg3 Argument to be passed on to the functor.
* @param _A_arg4 Argument to be passed on to the functor.
* @param _A_arg5 Argument to be passed on to the functor.
* @param _A_arg6 Argument to be passed on to the functor.
* @param _A_arg7 Argument to be passed on to the functor.
* @return The return value of the functor invocation.
*/
template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_arg7>
typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type
operator()(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6, T_arg7 _A_arg7) const
{ return functor_(_A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5, _A_arg6, _A_arg7); }
#ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_arg7>
typename deduce_result_type<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::type
sun_forte_workaround(T_arg1 _A_arg1, T_arg2 _A_arg2, T_arg3 _A_arg3, T_arg4 _A_arg4, T_arg5 _A_arg5, T_arg6 _A_arg6, T_arg7 _A_arg7) const
{ //Just calling operator() tries to copy the argument:
return functor_(_A_arg1, _A_arg2, _A_arg3, _A_arg4, _A_arg5, _A_arg6, _A_arg7);
}
#endif
/// Constructs an invalid functor.
adaptor_functor()
{}
/** Constructs an adaptor_functor object that wraps the passed functor.
* @param _A_functor Functor to invoke from operator()().
*/
explicit adaptor_functor(const T_functor& _A_functor)
: functor_(_A_functor)
{}
/** Constructs an adaptor_functor object that wraps the passed (member)
* function pointer.
* @param _A_type Pointer to function or class method to invoke from operator()().
*/
template <class T_type>
explicit adaptor_functor(const T_type& _A_type)
: functor_(_A_type)
{}
/// Functor that is invoked from operator()().
mutable T_functor functor_;
};
template <class T_functor>
typename adaptor_functor<T_functor>::result_type
adaptor_functor<T_functor>::operator()() const
{ return functor_(); }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
//template specialization of visitor<>::do_visit_each<>(action, functor):
/** Performs a functor on each of the targets of a functor.
* The function overload for sigc::adaptor_functor performs a functor
* on the functor stored in the sigc::adaptor_functor object.
*
* @ingroup adaptors
*/
template <class T_functor>
struct visitor<adaptor_functor<T_functor> >
{
template <class T_action>
static void do_visit_each(const T_action& _A_action,
const adaptor_functor<T_functor>& _A_target)
{
sigc::visit_each(_A_action, _A_target.functor_);
}
};
#endif // DOXYGEN_SHOULD_SKIP_THIS
/** Trait that specifies what is the adaptor version of a functor type.
* Template specializations for sigc::adaptor_base derived functors,
* for function pointers and for class methods are provided.
*
* The template argument @e T_functor is the functor type to convert.
* @e I_isadaptor indicates whether @e T_functor inherits from sigc::adaptor_base.
*
* @ingroup adaptors
*/
#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <class T_functor, bool I_isadaptor = std::is_base_of<adaptor_base, T_functor>::value> struct adaptor_trait;
#else
template <class T_functor, bool I_isadaptor = std::is_base_of<adaptor_base, T_functor>::value> struct adaptor_trait {};
#endif
/** Trait that specifies what is the adaptor version of a functor type.
* This template specialization is used for types that inherit from adaptor_base.
* adaptor_type is equal to @p T_functor in this case.
*/
template <class T_functor>
struct adaptor_trait<T_functor, true>
{
typedef typename T_functor::result_type result_type;
typedef T_functor functor_type;
typedef T_functor adaptor_type;
};
/** Trait that specifies what is the adaptor version of a functor type.
* This template specialization is used for arbitrary functors,
* for function pointers and for class methods are provided.
* The latter are converted into @p pointer_functor or @p mem_functor types.
* adaptor_type is equal to @p adaptor_functor<functor_type>.
*/
template <class T_functor>
struct adaptor_trait<T_functor, false>
{
typedef typename functor_trait<T_functor>::result_type result_type;
typedef typename functor_trait<T_functor>::functor_type functor_type;
typedef adaptor_functor<functor_type> adaptor_type;
};
// Doxygen (at least version 1.8.4) removes blank lines in a code block.
// That's why there are empty comment lines in the following code block.
/** Base type for adaptors.
* sigc::adapts wraps adaptors, functors, function pointers and class methods.
* It contains a single member functor which is always a sigc::adaptor_base.
* The typedef adaptor_type defines the exact type that is used
* to store the adaptor, functor, function pointer or class method passed
* into the constructor. It differs from @a T_functor unless @a T_functor
* inherits from sigc::adaptor_base.
*
* @par Example of a simple adaptor:
* @code
* namespace my_ns
* {
* template <class T_functor>
* struct my_adaptor : public sigc::adapts<T_functor>
* {
* template <class T_arg1=void, class T_arg2=void>
* struct deduce_result_type
* { typedef sigc::deduce_result_t<T_functor, T_arg1, T_arg2> type; };
* typedef typename sigc::functor_trait<T_functor>::result_type result_type;
* //
* result_type
* operator()() const;
* //
* template <class T_arg1>
* typename deduce_result_type<T_arg1>::type
* operator()(T_arg1 _A_arg1) const;
* //
* template <class T_arg1, class T_arg2>
* typename deduce_result_type<T_arg1, T_arg2>::type
* operator()(T_arg1 _A_arg1, T_arg2 _A_arg2) const;
* //
* // Constructs a my_adaptor object that wraps the passed functor.
* // Initializes adapts<T_functor>::functor_, which is invoked from operator()().
* explicit my_adaptor(const T_functor& _A_functor)
* : sigc::adapts<T_functor>(_A_functor) {}
* };
* } // end namespace my_ns
* //
* // Specialization of sigc::visitor for my_adaptor.
* namespace sigc
* {
* template <class T_functor>
* struct visitor<my_ns::my_adaptor<T_functor> >
* {
* template <class T_action>
* static void do_visit_each(const T_action& _A_action,
* const my_ns::my_adaptor<T_functor>& _A_target)
* {
* sigc::visit_each(_A_action, _A_target.functor_);
* }
* };
* } // end namespace sigc
* @endcode
*
* If you implement your own adaptor, you must also provide your specialization
* of sigc::visitor<>::do_visit_each<>() that will forward the call to the functor(s)
* your adapter is wrapping. Otherwise, pointers stored within the functor won't be
* invalidated when a sigc::trackable object is destroyed and you can end up
* executing callbacks on destroyed objects.
*
* Your specialization of sigc::visitor<> must be in namespace sigc.
*
* @ingroup adaptors
*/
template <class T_functor>
struct adapts : public adaptor_base
{
typedef typename adaptor_trait<T_functor>::result_type result_type;
typedef typename adaptor_trait<T_functor>::adaptor_type adaptor_type;
/** Constructs an adaptor that wraps the passed functor.
* @param _A_functor Functor to invoke from operator()().
*/
explicit adapts(const T_functor& _A_functor)
: functor_(_A_functor)
{}
/// Adaptor that is invoked from operator()().
mutable adaptor_type functor_;
};
} /* namespace sigc */
#endif /* _SIGC_ADAPTORS_ADAPTOR_TRAIT_H_ */
|