Julia,
The only way I can think of accomplishing this is to have all the methods
have the same return type. function<void> and function<int> are two
distinct types. Assigning them both to a function<void> just doesn't seem
right.
Jeff
-----Original Message-----
From: news [mailto:news@main.gmane.org]On Behalf Of Julia Donawald
Sent: Tuesday, September 03, 2002 8:22 AM
To: boost-users@yahoogroups.com
Subject: [Boost-Users] boost::function map with different return types
Hi,
I have the following code:
---------------
#include
#include
#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 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
Info: http://www.boost.org
Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl
Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/