noexcept的作用
时间: 2024-04-25 21:23:59 浏览: 19
noexcept的作用是在函数声明中指示该函数是否会抛出异常。它有几种写法,包括noexcept、noexcept(true)、noexcept(false)、noexcept(expression)和throw()。其中,默认的noexcept表示noexcept(true),表示函数不会抛出异常。当noexcept为true时,函数不会抛出异常;当noexcept为false时,函数可能会抛出异常。而throw()表示函数可能会抛出异常,但不建议使用该写法,应该使用noexcept(false)。noexcept函数用来检查一个函数是否声明了noexcept,如果声明了noexcept(true)则返回true,如果声明了noexcept(false)则返回false。\[1\]\[2\]\[3\]
#### 引用[.reference_title]
- *1* *2* *3* [noexcept 修饰符](https://blog.csdn.net/yaoyaohyl/article/details/127423150)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)