471,582 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

functors with reference parameters


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

Jul 19 '05 #1
0 1653

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by nsgi_2004 | last post: by
2 posts views Thread by vsgdp | last post: by
4 posts views Thread by Fraser Ross | last post: by
2 posts views Thread by leaf | last post: by
4 posts views Thread by tryptik | last post: by
2 posts views Thread by Jon Slaughter | last post: by
4 posts views Thread by Christopher | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.