How to Compile boost::function With a NoArg Member Function ?
Hi,
I need to use boost::function in a context like this one:
struct Widget {
string ToString() {return "Widget"; }
};
int main()
{
function
On Thu, 17 Jun 2004, Eduardo Bezerra wrote:
Hi,
I need to use boost::function in a context like this one:
struct Widget { string ToString() {return "Widget"; } };
int main() { function
What's the correct syntax to sucessfully compile this example ?
To call the ToString() method, you need to have an object of type Widget.
In the code above, there is no such object, so it fails to compile. There
are two options:
(a) You want to pass a pointer/reference to the widget into the
boost::function object so "f" can work on any widget, or
(b) You want to store a pointer/reference to a particular widget and
pass nothing to the boost::function object "f".
For (a), you need only specify whether you want to pass in a pointer or a
reference, e.g.,
int main()
{
function
participants (2)
-
Douglas Paul Gregor
-
Eduardo Bezerra