Static assertions are stated to be a solution to the gap between the
runtime assertions and precompiler assertions neither of which meet
the needs of the template library writer.
Similarly there is a gap between "if" and #if. Much of the obtuse
template trickery that we perform and the obese code we generate from
the precompiler is a result of our inability to include or exclude
code at compile time as simply as using "if".
The D programming language following other languages such as Ada,
contains conditional compilation ("static if") which allows particular
blocks of code to be included or excluded according to conditions
checked at compile time.
I must run now. But the point is. This seems to me a wonderful thing
but is there a reason why it could not be included into C++?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std...@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Can't you do that with #ifdef and/or #ifndef?
No. The preprocessor is not able to interact with other C++ code. For
example, the preprocessor cannot evaluate the "sizeof" operator or check
for the existence of various function signatures.