R
red floyd
Disclaimer: VS.NET 2003 (haven't checked any other compiler).
I'm writing functors for my classes.
Because the objects in my containers are large, I'm making my functors take const T& parameters.
If I try std::bind2nd() with one of these classes, I get an error about a reference to a reference.
What's the proper way to declare functors taking const T& parameters so that they play nicely with adapters?
Would it be something like the following? What should I use as the params to unary_function? I can't quite
figure it out from Josuttis.
class myClass
{
// internals redacted
};
class myFunctor : public std::unary_function<myClass, void>
{
public:
void operator()(const myClass& elem)
{
// do something with elem here
}
};
TIA
I'm writing functors for my classes.
Because the objects in my containers are large, I'm making my functors take const T& parameters.
If I try std::bind2nd() with one of these classes, I get an error about a reference to a reference.
What's the proper way to declare functors taking const T& parameters so that they play nicely with adapters?
Would it be something like the following? What should I use as the params to unary_function? I can't quite
figure it out from Josuttis.
class myClass
{
// internals redacted
};
class myFunctor : public std::unary_function<myClass, void>
{
public:
void operator()(const myClass& elem)
{
// do something with elem here
}
};
TIA