__________________________________________________ _____________
template<
typename T,
void (T::*T_fp_start) () = &T::start,
void (T::*T_fp_join) () = &T::join
struct active {T object;
struct guard {
T& object;
guard(T& _object) : object(_object) {
(object.*T_fp_start)();
}
~guard() {
(object.*T_fp_join)();
}
};
active() {
(object.*T_fp_start)();
}
~active() {
(object.*T_fp_join)();
}
};
__________________________________________________ _____________
Basically, I want to allow objects which have a common interface of
`T::start()/join()' to be able to use the template above like:
active<objecto;
However, if an object has a custom function it wants to use instead of start
and/or join, it could do something like:
active<object, &object::spawno;
-or-
active<object, &object::spawn, &object::waito;
Is that okay? I am not a C++ expert. However, it seems to compile on GCC and
Comeau...
;^)
--
Chris M. Thomasson
http://appcore.home.comcast.net