Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the noexcept operator in Clipper 11

Shulou Source: shulou.com Published: 2022-06-01 19:48:41 09月18日 Update

This article mainly explains "how to use the noexcept operator in Clippers 11". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the noexcept operator in Clippers 11.

The argument specified by the exception character

The previous article did not mention that the noexcept specifier can actually accept a parameter of type bool.

If the argument is true, it means that the function will not throw an exception, otherwise it may throw an exception. This approach is useful in situations where it is not certain whether an exception is thrown, such as the following template function:

In fun, the assignment statement does not throw an exception if the type of T is simple data (such as int); if the type of T is a class (such as string), the assignment statement may throw an exception. Is_pod is used in the code to determine whether the data is POD (Plain Old Data type) to determine whether the fun is noexcept. The sample code is as follows:

The output is as follows:

Noexcept operator

Clocking 11 also provides a noexcept operator to confirm whether a handler will throw an exception. For example, the following code:

Whether fun2 will throw an exception depends on whether fun will throw an exception. The code first uses the noexcept operator to calculate whether fun (ajar b) throws an exception, and the result is a Boolean value that happens to be the parameter of the noexcept specifier. The sample code is as follows:

The output is as follows:

At this point, I believe you have a deeper understanding of "how to use the noexcept operator in Clippers 11". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Operators operations code functions types results content parameters actual data examples statements specifiers processing learning output utility deeper interest practicality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei vpn OPPO Reno Shulou Technology