libsigc++: retype(), retype_return()

libsigc++ 3.8.1

Classes | Functions
retype(), retype_return()
Adaptors

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.
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.
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.

## 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);
  sigc::retype(sigc::ptr_fun(&foo))(5.7F); // calls foo(5)
  sigc::ptr_fun
  decltype(auto) ptr_fun(T_return(*func)(T_args...))
  Creates a functor of type sigc::pointer_functor which wraps an existing non-member function.
  Definition ptr_fun.h:107
  sigc::retype
  decltype(auto) 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...
  Definition retype.h:129

The functor that sigc::retype() returns can be passed directly into sigc::signal::connect() or sigc::signal::connect_first().

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 sigc::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
  std::ptr_fun
  pointer_to_unary_function< _Arg, _Result > ptr_fun(_Result(*__x)(_Arg))

## Function Documentation

## ◆ retype() [1/2]

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 | ) |
| 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.

## ◆ retype() [2/2]

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 | ) |
| 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.

## ◆ retype_return()

template <typename T_return , typename T_functor >

retype_return_functor< T_return, T_functor > sigc::retype_return | ( | const T_functor & | functor | ) |
| 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.