Semaphores and Events for C++11

The C++11 standard finally introduced mechanisms for platform independent multithreading and thread synchronisation. Unfortunately, the new language standard lacks a popular synchronisation primitive called semaphore (see The Little Book of Semaphores for an introduction). Fortunately, the built-in mutexes and condition_variables can be used to build fully-fledged semaphore objects:

Sierpinsky Triangle

Maybe the most elegant (obfuscated) way to generate a Sierpinski triangle :-)

main(){int k=1<<(6<<1);
while(k--){putchar((k>>
6)&~(k&((1<<6)-1))?(1<<
6-1):(1<<6));if(!(k&((1
<<6)-1)))putchar('\n');
}}