Boost logo

Boost :

From: Sergey Shandar (sergey_at_[hidden])
Date: 2007-11-07 01:55:17


Hello all

I have my own C++ framework (http://cbear.berlios.de, SVN:
http://tools.assembla.com/svn/cbear/trunk/) which has some useful (IMHO)
libraries. One of this library is "cast" library
(http://tools.assembla.com/cbear/browser/trunk/cbear.berlios.de/cast)
which allows you to convert objects without specifying a type:

char c;
int i;
...
// if(c == static_cast<char>(i))
if(c == cast::static_::value(i))
{
...
}

It is useful when you want to convert an object to a type of another
object. And this is also more safe, compare to standard casting, for
example in previous code someone can change the type of c to wchar_t,
and if you use static_cast, the compiler will not even warn you about
incorrect casting. So, you have to manually check all the code.

Currently there are several castings: static, reinterpret, const,
dynamic, polymorphic (based on Boost.polymorphic_cast), polymorphic_down
(based on Boost.polymorphic_downcast), explicit (calls an explicit
constructor), safe_reinterpret (compare sizes of converting types),
default (returns an object created by default constructor).

Thank you.

Best regards, Sergey Shandar.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk