Freestyling on patterns, idioms and semantics…

Icon

vivid hallucinations for bloodthirsty digital vampires

IoC revisited: from callback to closure!

I have been told to consider the IoC pattern for this series and I decided to explore it because I was not really familiar with this pattern.

Wikipedia defines IoC (Inversion of Control) as an abstract principle that describes an aspect of some software architecture design in which the flow control of a system is inverted in comparison to procedural programming. According to Martin Fowler, the term IoC is at least dated 1988, but, it’s still unclear whether it can be considered a pattern or just an architectural principle.

Read the rest of this entry »

Filed under: c++, C++11, programming

The Cool Factor(y)

With the coming of C++0x our previous C++ codes seem to have become too boilerplate. Among the number of important changes and improvements over the core language, the one I like most is the variadic template argument, a new semantic that enables the variable number of template arguments for both template classes and functions.

In turn, the variadic template arguments [VTA], along with the r-value reference that allows the perfect forwarding, enable users to design very compact patterns with a high level of code re-usability, opening the doors to a new way of writing generic code.

Read the rest of this entry »

Filed under: c++, C++11, programming

All the things you have always wanted to know about writing a generic perfect forwarder

A generic forwarder is a template function supposed to forward the passed arguments to a target function or a callable object (provided for example as an extra argument).

To be perfect a forwarder must be able to be deployed in different contexts, allowing to pass both lvalue and rvalue parameters, yet having the template parameter types correctly deducted and the target function properly chosen from a possible overloaded set.

The current C++ standard does not allow to implement such a perfect forwarder that instead is enabled by means of C++0x rvalue reference. Nevertheless, a generic non-perfect but correct forwarded is possible with the help of tr1::reference_wrapper.

Read the rest of this entry »

Filed under: c++, C++11, programming, ,

Follow me on twitter…

Error: Twitter did not respond. Please wait a few minutes and refresh this page.