CodePlea icon
Random thoughts on programming

C++ Callback Library: PlusCallback


Fork me on GitHub

PlusCallback is a C++ library, contained in a single header file, that implements easy to use function and method callbacks. It is completely contained in one header file, so it's trivial to add to your projects. It also uses the simplest syntax of any callback method I've ever seen (for C++), and it's quite flexible.

Code Sample

//Setup callback for TestObject.Foo().
cb::Callback1<int, int> callback(&TestObject, &TestClass::Foo);

//Call TestObject.Foo(5).

//Change callback to a free function.
callback = SomeRandomFunction;

//Call SomeRandomFunction(8).


  • Contained in one header file, trivial to install
  • Portable ANSI C++ code
  • Completely free for any use (zlib license)
  • Very simple API
  • Type-safe, no macros or casts
  • Container storage safe (e.g. std::map, list, vector, etc)