On 2/24/2010 17:09, bearophile wrote: > C++ has 4+1 casts, they are a good amount of complexity, and it's not > easy to learn their difference and purposes.
C++ casts perform three different logical functions: - Removing cv-qualifiers. (const_cast) - Reinterpreting raw bytes. (reinterpret_cast) - Converting values. (static_cast/dynamic_cast) These are clearly distinct function. Accidentally performing the wrong type of cast is clearly an error, and should be flagged by the compiler. Ideally, casts should be (distinct) library functions, not language features. The only thing vaguely confusing about the C++ system is the distinction between static_cast and dynamic_cast. I wouldn't mind seeing those two merged into a conversion_cast. -- Rainer Deyke - rain...@eldwood.com