'Meaningful' casts
summary
Implements concrete safer casts: to_num that checks overflow by promoting operands and using fenv/CFM checks, from_enum/to_enum that use std::underlying_type and enable_if to forbid invalid enum/number conversions, storage_cast that static_asserts size and alignment and copies CV qualifiers, and to_base/to_derived that tag-dispatches on std::is_polymorphic and uses dynamic_cast to assert correctness at runtime. Examples trigger compile errors or runtime assertions on overflow/mistyped enums and misaligned storage; points to Boost.NumericCast and Boost.polymorphic_cast and recommends compiler sanitizers (GCC/Clang) for production use.
AI-written summary · about
chapters (4)
related talks
45mBack to Basics: Casting
01h 12mCasts in C++: To lie... and hopefully - to lie usefully
01h 02mEmbedded Friendly C++: Features That Make a Difference
01h 01mEmbracing PODs Safely Until They Die
58mLeveraging C++20/23 Features for Low Level Interactions
56mEvolving a Nice Trick
07mType punning done right
39mReflection without Reflection TS
