Original Post
Hi
Im trying to write a functor class, but ran into problems when the "stored" function returns void.
My functor class has an invoke()-function and overloads the () operator. The return type is specified by the class template:
template << typename ObjectType, typename ReturnType >>
class Functor
{
.
.
ReturnType operator()()
{
return invoke(); // forward to invoke...
}
ReturnType invoke()
{
return (object->*method)();
}
};
As this is not possible in MSVC++ 6.0:
void f() {}
void g() {return f();}
... creating a functor with void as the return type does not compile:
Functor << MyClass, void >> fun; // error C2562: 'invoke' : 'void' function returning a valueIs there a way around this? I think boost's function can do this, but I don't understand how. Regards Mats Edit: The template parameters disappeard [edited by - Matsen on October 30, 2002 5:08:43 PM]