diff options
author | Henrik Kinnunen <fluxgen@fluxbox.org> | 2010-03-19 01:23:41 (GMT) |
---|---|---|
committer | Henrik Kinnunen <fluxgen@fluxbox.org> | 2010-03-19 01:23:41 (GMT) |
commit | ceff86b79401c27ed83cad65f59a6621c9a58084 (patch) | |
tree | 3dc59ecc1a7a5b31b2d87686aacc3c6e2dbdc5ab /src/FbTk/STLUtil.hh | |
parent | 68e90ab84fc8720264694de47c1ac33c401b49e5 (diff) | |
download | fluxbox_pavel-ceff86b79401c27ed83cad65f59a6621c9a58084.zip fluxbox_pavel-ceff86b79401c27ed83cad65f59a6621c9a58084.tar.bz2 |
Added SelectArg and MemFunSelectArg*
The MemFunSelectArg* functions can be used to select
a specific argument from a signal. For example this would
select the string argument as argument to the callback:
Signal<void, int, float, string> signal;
signal.connect(MemFunSelectArg2(obj, &Object::takesOneStringArg));
signal.emit(10, 3.14, "hello");
...
void Object::takesOneStringArg(const string& value) {
...
}
Diffstat (limited to 'src/FbTk/STLUtil.hh')
-rw-r--r-- | src/FbTk/STLUtil.hh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/FbTk/STLUtil.hh b/src/FbTk/STLUtil.hh index d427a17..e08036a 100644 --- a/src/FbTk/STLUtil.hh +++ b/src/FbTk/STLUtil.hh | |||
@@ -26,6 +26,25 @@ | |||
26 | namespace FbTk { | 26 | namespace FbTk { |
27 | namespace STLUtil { | 27 | namespace STLUtil { |
28 | 28 | ||
29 | template<bool C, typename Ta, typename Tb> | ||
30 | struct IfThenElse; | ||
31 | |||
32 | template<typename Ta, typename Tb> | ||
33 | struct IfThenElse<true, Ta, Tb> { | ||
34 | Ta& operator ()(Ta& ta, Tb& tb) const { | ||
35 | return ta; | ||
36 | } | ||
37 | typedef Ta ResultType; | ||
38 | }; | ||
39 | |||
40 | template<typename Ta, typename Tb> | ||
41 | struct IfThenElse<false, Ta, Tb> { | ||
42 | Tb& operator ()(Ta& ta, Tb& tb) const { | ||
43 | return tb; | ||
44 | } | ||
45 | typedef Tb ResultType; | ||
46 | }; | ||
47 | |||
29 | /// calls delete on each item in the container and then clears the container | 48 | /// calls delete on each item in the container and then clears the container |
30 | template <typename A> | 49 | template <typename A> |
31 | void destroyAndClear(A &a) { | 50 | void destroyAndClear(A &a) { |