Boost logo

Boost :

From: Trevor Perrin (tperrin_at_[hidden])
Date: 2001-03-02 15:06:47

Hi Dave,

thanks for the advice. If I read type_traits directly, it seems like line B
should work (and so should line A, but it doesn't in VC++):

     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?

-----Original Message-----
From: Darin Adler [mailto:darin_at_[hidden]]
Sent: Friday, March 02, 2001 11:27 AM
To: boost_at_[hidden]; Trevor Perrin
Subject: unable to use shared_ptr<const int> on VC6

on 3/2/01 11:04 AM, Trevor Perrin at tperrin_at_[hidden] wrote:

> For example, shared_ptr<const int> didn't work (I'm using VC6 sp4) cause
> can't delete the pointer; maybe you could specialize shared_ptr for const
> types or something, but I'm not sure if that works for VC and I'm sort of
> over my head here.

That's a VC6 bug. You are supposed to be able to delete a const int * in
standard C++. There's a note on this subject in the standard [5.3.5/2]:
expression before it is used as the operand of the delete-expression."

To add a workaround in shared_ptr for the VC6 bug, we could consider a
workaround that uses the templates we have in boost that manipulate types to
construct an appropriate cast.

    -- Darin
