Click here to Skip to main content
15,909,953 members
Articles / Programming Languages / C++

Smart Numeric Casts to End the Agony of (int)... or static_cast<int>(...)

Rate me:
Please Sign up or sign in to vote.
4.83/5 (11 votes)
18 Apr 2022CPOL24 min read 11.3K   54   12  
Smart numeric conversion casts that resolve the issue of should I write (int) or a static_cast by being a better choice than both
Smart numeric conversion casts that are correctly applied using the C style cast syntax, have appropriately verbose and descriptive names and are more strongly typed and resilient to coding errors than a static_cast. In debug builds, exceptions will catch conversion overflows. In release builds, they have zero overhead.

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Retired
Spain Spain
Software Author with engineering, science and mathematical background.

Many years using C++ to develop responsive visualisations of fine grained dynamic information largely in the fields of public transport and supply logistics. Currently interested in what can be done to make the use of C++ cleaner, safer, and more comfortable.

Comments and Discussions