Tag Archives: GCC


Quoting Wikipedia:

The word thunk has at least three related meanings in computing science. A “thunk” may be:

  1. A piece of code to perform a delayed computation (similar to a closure)
  2. A feature of some virtual function table implementations (similar to a wrapper function)
  3. A mapping of machine data from one system-specific form to another, usually for compatibility reasons

In all three senses, the word refers to a piece of low-level code, usually machine-generated, that implements some detail of a particular software system.

In this post (whose name looks like an unrelated typo) we shall observe the need for a thunk of the second kind, in C++.

Continue reading Thunksgiving

Catching uncaught exceptions within terminate

The handler std::terminate() is called whenever the exception handling mechanism cannot find a suitable catch clause for a thrown exception (and in some other cases. For example, when an exception is thrown during the handling of another exception – see this GotW post about std::uncaught_exception). It is possible to define a custom handler by using std::set_terminate.

In this post we would like to create a terminate handler which will be able to catch the exception that led to its invocation, when there is one.

Continue reading Catching uncaught exceptions within terminate


One of the containers introduced within TR1 (which is already widely available – both in gcc and Visual Studio) is a Tuple type, which is adopted from The Boost Tuple Library. Tuple types are very convenient at times; For example, it is possible to return multiple values from a function through a tuple, or write more intuitive and expressive code by utilizing tuples.

In this post we will examine the functionality offered by the new Tuple container, and have a go at profiling its performance. Actually, the results of said profiling were a small (pleasant) surprise to me.

Continue reading Tuples