Disclaimer

The content of this blog is my personal opinion only. Although I am an employee - currently of Imagination Technologies's MIPS group, in the past of other companies such as Intellectual Ventures, Intel, AMD, Motorola, and Gould - I reveal this only so that the reader may account for any possible bias I may have towards my employer's products. The statements I make here in no way represent my employer's position, nor am I authorized to speak on behalf of my employer. In fact, this posting may not even represent my personal opinion, since occasionally I play devil's advocate.

See http://docs.google.com/View?id=dcxddbtr_23cg5thdfj for photo credits.

Saturday, December 13, 2008

Why RAII is convenient

RAII is convenient in C++.

Essentially, it is the trick of using the destructor to do something like arrange flr printing of a data structure.

Essentially, it is a trivial form of introspection.Practically the only way in C++ than you can automatically traverse a type, and al of its members.

Today, I would like to automatically create a print function. I am tempted to use RAII, so that it gets printed at destruction. That seems silly, however; but it is the only way I know to autromatically call a method on all members.

No comments: