How now correctly to specify that function throws out exceptions? Write throw(...) or list possible exceptions or write nothing at all?
And another question: what is indicated in brackets after noexcept ?
How now correctly to specify that function throws out exceptions? Write throw(...) or list possible exceptions or write nothing at all?
And another question: what is indicated in brackets after noexcept ?
If the function throws an exception, then write nothing. (Or you can equivalently write noexcept(false) ).
What is indicated in brackets noexcept depends on what noexcept you are talking about. There is a noexcept operator , and there is a noexcept .
The noexcept operator checks the noexcept status of an expression. This is the compile time operator. The operand is an expression whose noexcept status you want to know. The compiled operator will return true or false .
The noexcept contrary assigns the noexcept-status of the function. It declares whether a given function is noexcept or not. Just noexcept says the function is noexcept . And in the variant with the Boolean operand, the noexcept-status is determined by the value of the Boolean expression.
For example, the following example uses both the noexcept operator and the noexcept specifier noexcept
void bar() noexcept(noexcept(foo())); ^ ^ | | | оператор спецификатор The bar() function will result in the same noexcept-status as the foo() function.
Source: https://ru.stackoverflow.com/questions/632485/
All Articles