"Fossies" - the Fresh Open Source Software Archive

Member "libsigc++-3.0.0/docs/docs/reference/html/group__track__obj.html" (5 Sep 2019, 8490 Bytes) of package /linux/misc/libsigc++-3.0.0.tar.xz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the project site itself.

libsigc++  3.0.0
Classes | Functions
track_obj()

sigc::track_obj() tracks trackable objects, referenced from a functor. More...

Classes

class  sigc::track_obj_functor< T_functor, T_obj >
 track_obj_functor wraps a functor and stores a reference to a trackable object. More...
 

Functions

template<typename T_functor , typename... T_obj>
decltype(auto) sigc::track_obj (const T_functor& func, const T_obj&...obj)
 Creates an adaptor of type sigc::track_obj_functor which wraps a functor. More...
 

Detailed Description

sigc::track_obj() tracks trackable objects, referenced from a functor.

It can be useful when you assign a C++11 lambda expression or a std::function<> to a slot, or connect it to a signal, and the lambda expression or std::function<> contains references to sigc::trackable derived objects.

The functor returned by sigc::track_obj() is formally an adaptor, but it does not alter the signature, return type or behaviour of the supplied functor.

Example:
struct bar : public sigc::trackable {};
sigc::signal<void()> some_signal;
void foo(bar&);
{
bar some_bar;
some_signal.connect([&some_bar](){ foo(some_bar); });
// NOT disconnected automatically when some_bar goes out of scope
some_signal.connect(sigc::track_obj([&some_bar](){ foo(some_bar); }, some_bar);
// disconnected automatically when some_bar goes out of scope
}
Since libsigc++ 2.4:

Function Documentation

template <typename T_functor , typename... T_obj>
decltype(auto) sigc::track_obj ( const T_functor &  func,
const T_obj &...  obj 
)
inline

Creates an adaptor of type sigc::track_obj_functor which wraps a functor.

Parameters
funcFunctor that shall be wrapped.
objTrackable objects.
Returns
Adaptor that executes func() on invocation.
Since libsigc++ 2.4: