libsigc++: retype(), retype_return()
sigc::retype() alters a sigc::pointer_functor, a sigc::mem_functor or a sigc::slot in that it makes C-style casts to the functor's parameter types of all parameters passed through operator()(). More...
Classes | |
struct | sigc::retype_functor< T_functor, T_type > |
Adaptor that performs C-style casts on the parameters passed on to the functor. More... | |
struct | sigc::retype_return_functor< T_return, T_functor > |
Adaptor that performs a C-style cast on the return value of a functor. More... | |
struct | sigc::retype_return_functor< void, T_functor > |
Adaptor that performs a C-style cast on the return value of a functor. More... | |
Functions | |
template<template< typename T_func, typename...T_arg > class T_functor, typename T_func , typename... T_arg> | |
decltype(auto) | sigc::retype (const T_functor< T_func, T_arg... >& functor) |
Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on to the functor. More... | |
template<template< typename T_return, typename...T_arg > class T_functor, typename T_return , typename... T_arg> | |
decltype(auto) | sigc::retype (const T_functor< T_return(T_arg...)>& functor) |
Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on to the functor. More... | |
template<typename T_return , typename T_functor > | |
retype_return_functor< T_return, T_functor > | sigc::retype_return (const T_functor& functor) |
Creates an adaptor of type sigc::retype_return_functor which performs a C-style cast on the return value of the passed functor. More... | |
Detailed Description
sigc::retype() alters a sigc::pointer_functor, a sigc::mem_functor or a sigc::slot in that it makes C-style casts to the functor's parameter types of all parameters passed through operator()().
Use this adaptor for inline conversion between numeric or other simple types.
- Example:
- void foo(int);
The functor that sigc::retype() returns can be passed directly into sigc::signal::connect().
- Example:
- sigc::signal<void(float)> some_signal;void foo(int);some_signal.connect(sigc::retype(sigc::ptr_fun(&foo)));
This adaptor builds an exception in that it only works on sig::pointer_functor, sigc::mem_functor and sigc::slot because it needs sophisticated information about the parameter types that cannot be deduced from arbitrary functor types.
sigc::retype_return() alters the return type of an arbitrary functor. Like in sigc::retype() a C-style cast is performed. Usage sigc::retype_return() is not restricted to libsigc++ functor types but you need to specify the new return type as a template parameter.
- Example:
- float foo();std::cout << sigc::retype_return<int>(&foo)(); // converts foo's return value to an integer
Function Documentation
|
inline |
Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on to the functor.
- Parameters
-
functor Functor that should be wrapped.
- Returns
- Adaptor that executes functor performing C-style casts on the paramters passed on.
|
inline |
Creates an adaptor of type sigc::retype_functor which performs C-style casts on the parameters passed on to the functor.
- Parameters
-
functor Functor that should be wrapped.
- Returns
- Adaptor that executes functor performing C-style casts on the paramters passed on.
|
inline |
Creates an adaptor of type sigc::retype_return_functor which performs a C-style cast on the return value of the passed functor.
The template argument T_return specifies the target type of the cast.
- Parameters
-
functor Functor that should be wrapped.
- Returns
- Adaptor that executes functor performing a C-style cast on the return value.