Pizer’s Weblog

programming, DSP, math

Posts Tagged ‘function

A little C++0x finger exercise

with 4 comments

Since the C++ compiler of GCC 4.3.2 comes with partial C++0x support and I had not tested all of these features yet, I decided to do a little finger exercise: “function”.

“function” is a useful library feature of Boost, TR1, and the upcoming C++ standard library. It’s basically a class template mimicing the behaviour of a function pointer. But it’s much more flexible because it applies to any “callable object” — function pointers and objects with overloaded function call operator. Also, the signatures don’t have to match perfectly as long as the parameters and return values are implicitly convertible. I’m going to show you how this library feature can be implemented with C++0x features — including variadic templates and rvalue references. But before going into any details let me give an example of how code that uses this “function” library might look like. In case you’re already familiar with this library feature you can skip the following piece of code and paragraph of text.

Read the rest of this entry »


Written by pizer

March 28, 2009 at 9:59 pm