Why is boost::checked_delete "intentionally complex"?

Viewed 580

So I was looking through some boost source code and came across this:

(from <boost/checked_delete.hpp>)

template<class T> inline void checked_delete(T * x)
{
    // intentionally complex - simplification causes regressions
    typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
    (void) sizeof(type_must_be_complete);
    delete x;
}

Anyone happen to know why it is implemented in this way? Wouldn't sizeof(T) (for example) already be enough?

2 Answers
Related