|
Boost Users : |
From: Julia Donawald (yg-boost-users_at_[hidden])
Date: 2002-09-03 10:21:46
Hi,
I have the following code:
---------------
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <map>
#include <string>
class Foo {
public:
void Function3() const
{
int i =2;
};
const std::string Function4() const
{
return "";
};
unsigned int Function5() const
{
return 2;
};
};
std::map<std::string, boost::function<void> > functions;
Foo foo;
functions["Function3"] = boost::bind(&Foo::Function3, &foo);
functions["Function4"] = boost::bind(&Foo::Function4, &foo);
functions["Function5"] = boost::bind(&Foo::Function5, &foo);
// call the functions
functions["Function4"]();
--------------
Calling the correct function with the entries in the map is no problem, but
how can I get the return value. I tried something like that:
"unsigned int i = functions["Function5"]();" but sadly it doesnt work, maybe
cause in the map I declared for the return value "void"?
How can I have such a map where to have functions with different return
types in it and to get the return value after a call of the function through
the map?
Thanks in advance
Julia
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net