|
Boost : |
From: John Maddock (john_at_[hidden])
Date: 2007-09-12 12:45:24
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk