From: Peder Holt (peder.holt_at_[hidden])
Date: 2007-11-25 16:27:30
Is there a way to detect at compile time whether you are running code
analysis or not?
The 'native' typeof implementation for Visual Studio uses a hack to deduce
the type of an expression. Originally, the type of the expression was
coupled with a compile time integer in order to be able to access the type
later, so all you need to do is take the size of some template function and
ask the deducer about what type it corresponds to.
This method works, but we experienced some problems with ICEs on VC7.1 and
VC8.0, so I started experimenting with using typeid in stead
(extract_type<typeid(encode_type(expr))>::type). Completely nonstandard, but
so is the rest of the hack, so why not. This seemed to eliminate the ICEs on
mentioned platforms, and also eliminated the limit on number of typeof
invocations in a single compilation unit (~1000)
Now it turns out that microsofts code analysis tool complains about the use
of typeid. When using sizeof, reverting to sizeof, it also ICES on the
typedef BOOST_TYPEOF_TPL(&f) type;
It would be nice to disable code analysis for this piece of code.
I'll revert the code to using sizeof for now.