[sigc] Clarifying the behavior of sigc::slot_base::operator bool
- From: James Lin <jameslin vmware com>
- To: "libsigc-list gnome org" <libsigc-list gnome org>
- Subject: [sigc] Clarifying the behavior of sigc::slot_base::operator bool
- Date: Wed, 23 Sep 2009 17:27:14 -0700
Hello,
What should the expected output be for:
void bar(void) { }
sigc::slot<void> foo = sigc::ptr_fun(&bar);
foo = sigc::slot<void>();
std::cout << bool(foo) << std::endl;
?
I get "1" (using MSVC 2008 with libsigc++ 2.2.4.2), which surprised me. sigc::slot_base::empty() also returns true in this case. Is this subtle distinction intentional? The documentation for operator bool says:
"Tests whether a slot is null, because the default constructor was used."
On one hand, I didn't initialize the slot with the default constructor (although I did assign over it with a default-constructed slot). On the other hand, I think it qualifies as a "null slot".
Thanks,
- James
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]