Can a noexcept function still call a function that throws in C++17?

前端 未结 4 1993
没有蜡笔的小新
没有蜡笔的小新 2021-02-15 13:08

In P0012R1, \"Make exception specifications be part of the type system\",
I see that noexcept is now becoming a part of the function type.

I

4条回答
  •  轮回少年
    2021-02-15 13:42

    According to cppreference:

    Note that a noexcept specification on a function is not a compile-time check; it is merely a method for a programmer to inform the compiler whether or not a function should throw exceptions.

    So the syntax of your code is valid, but std::terminate will be called when executed.

提交回复
热议问题