WTF are functors, and how do they work?

Started by
10 comments, last by Toolmaker 20 years, 6 months ago
Ok, I misunderstood you. But, why use boost? As far as I can see, I just need to be able to store a function pointer to something like myclass::foo(...).

I might be stupid or stubborn(spelling?), but I rather don''t use a large library for this. If someone can explain this to be, thx, otherwise, I gotta use boost...

Toolmaker


-Earth is 98% full. Please delete anybody you can.

Advertisement
Please do not fall into Gamedev.net "Not Written Here Syndrome." Boost is not a large library:
* it is header-only with a few exceptions
* the linker strips out every definition not used in your final program anyway

You use boost for reasons I already mentioned in another thread:
They use a preprocessor written in C++ to generate templates for function pointers taking 1-50 arguments. These arguments can be of any type, but you have to have one definition of the function (called boost::functionN, where N is a number) for each number of arguments in the callback.

They are type-safe and easy to work with once you get the hang of them. In short, don''t look at gift horse in the mouth, I''ll take stuff they write over anyone''s homebrewed implementation (often the only justification people give for it is "it isn''t my naming convention.") Several of them are on the C++ standards committee, and they are quite smart.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis

This topic is closed to new replies.

Advertisement