The C++ Standard Library: A Tutorial and Reference

Author: Nicolai M. Josuttis
All Stack Overflow 22


by anonymous   2017-08-20

If you want dead trees, maybe you'd be better off with a proper book? I found this one indispensable: The C++ Standard Library: A Tutorial and Reference by Nicolai M. Josuttis

by anonymous   2017-08-20

The best way to figure out what's happening 'under the bonnet' is to actually look under the hood and find the source code :)

Otherwise just read the documentation. I recommend this site, or this book.

by anonymous   2017-08-20

I believe your question is ill-posed. Look at what you have: a small one-liner function add_size and a call to std::accumulate. What's not to like?

You are somehow (for perhaps corporate reasons) restricted from using either Boost.Bind or Boost.Lambda, let alone C++11 (which standardized both std::bind and lambda expressions).

You want to eliminate that in favor of the C++03 binders which are horribly limited in their expressiveness (which is BTW one reason why Boost.Bind and Boost.Lambda were so popular) and would require much more boilerplate than what you currently have. Look at this appendix of the C++ Standard Reference book by Nicolai Jusuttis. He implements a general compose template that works "nicely" with std::bind2nd and friends. But look at which headers he uses to implement that: right, the Boost.Bind ones.

Your best approach is to simply copy Boost.Bind and/or Boost.Lambda, put them in your own source tree, and rename the namespace to your company's. Check whether this is in fact consistent with the Boost License. Boost even has a bcp tool to extract all the included dependencies for you. Then simply write whatever you need to using the bind or lambda facilities that you've just "written".

TL;DR: Do not Re-invent the Wheel. Familiarize yourself with Boost.