Boost logo

Boost Users :

From: Sean DeNigris (lotusone_at_[hidden])
Date: 2005-04-20 20:59:34


Hey-hey,

Is it proper to to use static_cast like this:

 

//Library.h - legacy library

typedef ??? Type; //library-defined, we don't know the actual type

typedef Type* PType; //library-defined pointer type

 

//sets bufSize to # bytes necessary if buf not big enough

LibraryFunction(PType buf, int* bufSize);

 

//MyCode.cpp

int bytesNeeded = 0;

LibraryFunction(0, &bytesNeeded);

scoped_array<Type>(static_cast<PType>(new BYTE[bytesNeeded]));

 

The legacy library tells us storage requirements in BYTEs, but I want to
deal with 'Type's, not BYTEs.

 

Is there a conceivable reason why this could not be safe, even if it happens
to be with the current implementation?

Thanks.

- Sean



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net