|
Boost : |
From: vesa_karvonen (vesa_karvonen_at_[hidden])
Date: 2002-01-24 11:06:29
I just committed a fun preprocessor example into the CVS.
The DELAY() macro implemented in the example source takes exponential
time to expand into nothing. For instance, on the 800MHz PIII I use
at the office, it takes roughly 4 seconds to compile delay.cpp like
this on the MSVC++ compiler:
cl -Zs -nologo -I../../.. -DDELAY_MAX=15 delay.cpp
The maximum argument to delay is 50. This means that if I use the
command:
cl -Zs -nologo -I../../.. -DDELAY_MAX=50 delay.cpp
It takes roughly 4000 years to complete.
As an interesting technical detail, DELAY() takes a constant amount
of memory to compile. Similar delaying tricks can be done using
template metaprogramming, but they do not work very well, because
template instantiation takes a lot of memory, so eventually the
computer runs out of memory.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk