libsigc++  3.6.0
Public Types | Public Member Functions | List of all members
sigc::limit_reference< T_type, I_derives_trackable > Class Template Reference

A limit_reference<Foo> object stores a reference (Foo&), but makes sure that, if Foo inherits from sigc::trackable, then visit_each<>() will "limit" itself to the sigc::trackable reference instead of the derived reference. More...

#include <sigc++/limit_reference.h>

Public Types

using reference_type = typename std::remove_volatile_t< T_type >
 

Public Member Functions

 limit_reference ()=delete
 
 limit_reference (const limit_reference & src)=default
 
 limit_reference (limit_reference && src)=default
 
 limit_reference (reference_type & target)
 Constructor. More...
 
T_type & invoke () const
 Retrieve the reference. More...
 
limit_referenceoperator= (const limit_reference & src)=default
 
limit_referenceoperator= (limit_reference && src)=default
 
const reference_typevisit () const
 Retrieve the entity to visit for visit_each(). More...
 

Detailed Description

template<typename T_type, bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
class sigc::limit_reference< T_type, I_derives_trackable >

A limit_reference<Foo> object stores a reference (Foo&), but makes sure that, if Foo inherits from sigc::trackable, then visit_each<>() will "limit" itself to the sigc::trackable reference instead of the derived reference.

This avoids use of a reference to the derived type when the derived destructor has run. That can be a problem when using virtual inheritance.

If Foo inherits from trackable then both the derived reference and the sigc::trackable reference are stored, so we can later retrieve the sigc::trackable reference without doing an implicit conversion. To retrieve the derived reference (so that you invoke methods or members of it), use invoke(). To retrieve the trackable reference (so that you can call visit_each() on it), you use visit().

If Foo does not inherit from sigc::trackable then invoke() and visit() just return the derived reference.

This is used for bound (sigc::bind) slot parameters (via bound_argument), bound return values, and, with mem_fun(), the reference to the handling object.

Member Typedef Documentation

◆ reference_type

template <typename T_type , bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
using sigc::limit_reference< T_type, I_derives_trackable >::reference_type = typename std::remove_volatile_t<T_type>

Constructor & Destructor Documentation

◆ limit_reference() [1/4]

template <typename T_type , bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
sigc::limit_reference< T_type, I_derives_trackable >::limit_reference ( )
delete

◆ limit_reference() [2/4]

template <typename T_type , bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
sigc::limit_reference< T_type, I_derives_trackable >::limit_reference ( reference_type target)
inlineexplicit

Constructor.

Parameters
targetThe reference to limit.

◆ limit_reference() [3/4]

template <typename T_type , bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
sigc::limit_reference< T_type, I_derives_trackable >::limit_reference ( const limit_reference< T_type, I_derives_trackable > &  src)
default

◆ limit_reference() [4/4]

template <typename T_type , bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
sigc::limit_reference< T_type, I_derives_trackable >::limit_reference ( limit_reference< T_type, I_derives_trackable > &&  src)
default

Member Function Documentation

◆ invoke()

template <typename T_type , bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
T_type& sigc::limit_reference< T_type, I_derives_trackable >::invoke ( ) const
inline

Retrieve the reference.

This is always a reference to the derived instance.

Returns
The reference.

◆ operator=() [1/2]

template <typename T_type , bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
limit_reference& sigc::limit_reference< T_type, I_derives_trackable >::operator= ( const limit_reference< T_type, I_derives_trackable > &  src)
default

◆ operator=() [2/2]

template <typename T_type , bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
limit_reference& sigc::limit_reference< T_type, I_derives_trackable >::operator= ( limit_reference< T_type, I_derives_trackable > &&  src)
default

◆ visit()

template <typename T_type , bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value>
const reference_type& sigc::limit_reference< T_type, I_derives_trackable >::visit ( ) const
inline

Retrieve the entity to visit for visit_each().

Depending on the template specialization, this is either a derived reference, or sigc::trackable& if T_type derives from sigc::trackable.

Returns
The reference.