Itay Maman wrote:
> "David B. Held" <[EMAIL PROTECTED]> wrote in message
> b2ug4i$a8q$[EMAIL PROTECTED]">news:b2ug4i$a8q$[EMAIL PROTECTED]...
>> "Eric Friedman" <[EMAIL PROTECTED]> wrote in message
>> b2uflv$86s$[EMAIL PROTECTED]">news:b2uflv$86s$[EMAIL PROTECTED]...
>>> [...]
>>>   const T& r = ...;
>>>   r.~T();
>>>
>>> Even if my understanding is correct though, it may be best for
>>> destroyer to take a non-const reference to avoid confusion.
>>
>> Comeau says it's ok, so I'd just leave it as is.  It does seem
>> peculiar to me, though.
>>
>> Dave
>>
>
> I was surprised to read that, but the standard says it is Kosher:
>
> [12.4.2]
>
> "...A destructor can  be  invoked  for  a  const,  volatile  or const
> volatile object.  A destructor shall not be declared const, volatile
> or const volatile (_class.this_).  const  and  volatile  semantics
> (_dcl.type.cv_) are not applied on an object under destruction."

Destroying a const object is fine, but there is no reason to have a const in
the argument.

template<class T> void call_destructor(T & t) { t.~T(); }

X const x;

f(x); // OK, T = X const

f(5); // compile-time fail

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to