If you look at the commentary on noexcept, there was an explanation that the function should specify when it does not send an exception.For what purpose is it used in practical use?What purpose do you use in your daily development to achieve in the end?
c++
For what practical purposes is it used?
noexcept
The designator is used for two main purposes:
Note that the presence or absence of noexcept
is considered part of the external public interface.Given that noexcept
specification for a function is a declaration "do not send an exception as an external specification for this function", it should not be given if there is a possibility of sending an exception in the future (which leads to very difficult and disruptive API specification changes).
C++ Core Guideline (same Title) provides some guidelines for using .
noexcept
noexcept
swap functionnoexcept
==
symmetric with inspect to operand types andnoexceptnoexcept
noexcept
when exiting a function cause of athrowis impossible or unacceptable
© 2024 OneMinuteCode. All rights reserved.noexcept
is a specification introduced in c++11, so it is a specification introduced in