Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What would the C++ program look like ideally

Shulou Source: shulou.com Published: 2022-06-01 19:12:08 10月03日 Update

This article mainly introduces "C++ ideal case program is what kind of", in daily operation, I believe many people in C++ ideal case program is what kind of problem there are doubts, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation method, hope to answer "C++ ideal case program is what kind of" doubts helpful! Next, please follow the small series to learn together!

Ideally, programs are completely static (compile-time) type-safe. Unfortunately, this is impossible. Problem areas include:

unions

casts (type conversion)

array decay

range errors

narrowing conversions

Note

These areas are sources of serious errors (e.g., crashes and security breaches). We strive to provide alternative technologies.

Enforcement

For individual programs, it is necessary and feasible to prohibit, restrict, or examine individual problem classes separately. We also offer alternatives, such as:

unions -- use variant (in C++17)

Union--using C++17 variant

casts -- minimize their use; templates can help

Type conversion--minimize their use, templates can help

array decay -- use span (from the GSL)

Array Destruction--Use span(from GSL)

range errors -- use span

Range Crops-Use span

narrowing conversions -- minimize their use and use narrow or narrow_cast (from the GSL) where they are necessary

Narrowing conversions-Minimize the use of type conversions and use narrow or narrow_cast when necessary (from GSL)

At this point, the study of "what C++ ideally looks like" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Program situation ideal Category Type Learning problem help Security necessity Array more scope error Domain Joint feasible practical and then unfortunately Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info vpn OPPO Reno Docker Xiaomi