A lightweight C++ signals and slots implementation
github.com
github.com
The code in the library is pretty old and I suppose that an update with regards to C++11/14/17 would make it much better in every regard.
gcc 5.3 (& co) for DOS!
http://www.codeproject.com/Articles/7150/Member-Function-Poi...
template<class T1 = default_, class T2 = default ..., class T10 = default_> struct Signal;
where default is a placeholder type, and then have it dispatch internally to the correct Signal/N/ via template specialization.
The template specialization themselves were generated either via preprocessor metaprogramming or by an external tool.
'Class template std::function is a general-purpose polymorphic function wrapper. Instances of std::function can store, copy, and invoke any Callable target -- functions, lambda expressions, bind expressions, or other function objects, as well as pointers to member functions and pointers to data members.'
This clearly does more than the OPs code and therefore has more complexity.
That said, popular implementations of std::function employ small object optimizations so the usescases that delegate supports doesn't incur heap allocations. I would guess that delegate has a slight upper hand when it comes to call performance. I really doubt the difference would matter when used in GUI programming.
It's a dependency injection mechanism when you think about it.
Someone posts a link to A and immediately there is a comment - "How is it better than B? How is it different from C?" You know what, bud, if you know about B and C, excellent. Why don't you take a look at A and do everyone a favor and answer your own question. Otherwise it sound like a lazy-ass highbrow dismissal - "Pfft, A? Why bother? There is B, for chrissake, that even the last imbecile here is familiar with."
Please try and make a sliver of effort when commenting on other people's work.
If the OP only wants to learn how to do it, or to build its portfolio for a possible job interview, it is fair enough and I don't need to bother with it.
If the author wants to do a kick-ass replacement of libsigc++, then it is probably worth my expensive time to look into it.
It's just an opportunity for me to express my extreme dislike for one line dismissive comments just asking "How is this better than X?".
If you are truly more interested, you should give more context and information. That's how I try to do it when I face similar interrogations.
:-) (joking, you are on the right track here, 100% agree)
How is this better than Xyz?
to How does this compare to Xyz?
It's one character longer, but it doesn't automatically imply that the original submission is a crap not worthy even a shortest glimpse. Unless of course the purpose of your comment was indeed to show that you are the royalty of the programming world whose time is very expensive.For example, recently someone linked to Dolphin smalltalk, and I asked how it was different than Pharo - I'm not an expert in either, and the answer was greatly illuminating.
Also, this kind of question usually leads to me looking at other items related to the thing posted that I was unaware of. I don't think it's a bad question at all. Hell, sometimes the author comes in to explain it!