Boost logo

Boost :

Subject: Re: [boost] boost/checked_delete.hpp
From: mbiddeg_at_[hidden]
Date: 2009-06-08 10:00:44

Thanks Peter.

This clears things up for me.

However, concerning the last point x is passed by reference (pointer), as in inline void checked_delete(T * x)

Thank you once again.


Kizza George Mbidde

Interconnect Billing Systems Analyst


cell: +256 77 221 2982

email: mbiddeg_at_[hidden]

-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Peter Dimov
Sent: Monday, June 08, 2009 16:52
To: boost_at_[hidden]
Subject: Re: [boost] boost/checked_delete.hpp

Kizza George Mbidde:


> typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];

> (void) sizeof(type_must_be_complete);

> delete x;


> * What's the result of applying sizeof to an incomplete type?

A compile-time error, unless the compiler chooses to return 0 as a

nonstandard extension.

> * Why is sizeof called twice?

The second sizeof is a workaround for a Metrowerks CodeWarrior bug in which

the first typeof is never instantiated unless used.

> * Why is the result of sizeof cast to void? What exactly does that line

> do?

Silences a compiler warning.

> * Is it an empty statement if the sizeof is legal?


> * Why not apply x = 0; at the end?

It wouldn't do anything as x is passed by value.

Peter Dimov
Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at