
12 Sep
2007
12 Sep
'07
4:45 p.m.
Johan RĂ¥de wrote:
When some type traits, for instance is_base_of, are called with incomplete types, then they may silently "return" incorrect results. It would be better if they failed to compile with incomplete types.
Here is a suggestion how that might be implemented:
template<int> struct assert_complete0 {};
template<typename T> struct assert_complete : public assert_complete0<sizeof(T)> {};
template<typename B, typename T> is_base_of : public assert_complete<B>, public assert_complete<T> ...
I have tested this with with VC 7.1, and it works. Will this work on other platforms? Are there any reasons not to add this check?
Nope, I've fixed this with a couple of static_asserts in the SVN trunk version. John.