Re: [sigc] How does std::function<> work with libsigc++
- From: Chris Vine <chris cvine freeserve co uk>
- To: Kjell Ahlstedt <kjell ahlstedt bredband net>
- Cc: libsigc-list gnome org, Murray Cumming <murrayc murrayc com>
- Subject: Re: [sigc] How does std::function<> work with libsigc++
- Date: Mon, 29 Jul 2013 20:54:30 +0100
On Mon, 29 Jul 2013 20:44:02 +0200
Kjell Ahlstedt <kjell ahlstedt bredband net> wrote:
Wouldn't it be cleaner to just (or also) add a specific
connect(std::function<>) method overload that did this
automatically?
Sure. I wish I knew how to do it. sigc::track_obj() forces you to
manually specify which trackable objects the functor contains. This
is not nearly as nice as the automatic detection of trackable objects
in the rest of libsigc++. The enormous use of C++ templates in
libsigc++ is near, or even beyond, the limits of my comprehension.
I have to say I disagree with that. One of the banes of libsigc++ is
that it makes any slot for a non-static method of a class deriving
from sigc::trackable as a tracked slot, which is sometimes what you do
not want. It is better to enable the user to choose when constructing
the slot.
I also would not encourage passing of std::function objects.
sigc::slot, when passed a callable object (such as a lambda expression
or the return value of std::bind), will perform type erasure on it in
the same way that std::function does. To do it twice (by passing a
std::function object to sigc::slot) results an unnecessary memory
allocation and an additional and unnecessary virtual dispatch.
Chris
[
Date Prev][Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]