Subject: Re: [boost] How to get the size of an C-array?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-10-14 20:02:37
Sid Sacek a écrit :
> I'm going to take a guess. Of course, this is all contingent on whether T is a class that contains a destructor, otherwise all bets are off.
> -Sid Sacek
> T * tp = new T[ 100 ];
> size_t array_size = reinterpret_cast< size_t * >( tp )[ -1 ];
I think this is not going to work if T has a stricter alignment than size_t.