Boost logo

Boost :

From: Ed Brey (brey_at_[hidden])
Date: 2001-03-02 16:12:36


From: "Trevor Perrin" <tperrin_at_[hidden]>
> const int* x = new int;
> (A) delete x;
> (B) delete const_cast<remove_const<const int*>::type>(x);
>
> But they both give:
> error C2665: 'delete' : none of the 2 overloads can convert parameter 1
from
> type 'const int *'
>
> Am I doing something wrong or is my compiler hosed? If the latter, are
> there any other potential workarounds?

Compiler is hosed. A workaround is to include this line in your handy-dandy
VC6 workaround header:
inline void operator delete(const void* p) throw() {operator
delete(const_cast<void*>(p));}

It would probably be a good thing to add this bug and workaround to the VC
known bug page, since it does affect significantly affect
Boost.SmartPointer. Also, to be more complete, one would add similar
workaround lines for deletion of const arrays, plus deletion with
std::nothrow.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk