C ++异常会阻止内联函数吗? [英] Would C++ exception stops function from being inlined?

查看:57
本文介绍了C ++异常会阻止内联函数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个非常简单的函数,希望编译器对其进行内联.但是我可能需要在看到一些无效输入时抛出异常,这会阻止编译器内联函数吗?

Suppose I have a very simple function that I expect the compiler to inline it. But I may need to throw exception on seeing some invalid input, would that stop the compiler from inlining the function?

推荐答案

编译器可以出于任何原因拒绝内联.gcc列出了它可能不内联函数的原因,但不会引发异常他们之中.同样,如果选项-Winline无法内嵌标记为内联的函数,则会导致编译器发出警告.您可以尝试一下,看看您是否正在采取任何措施来防止内联.

A compiler can refuse to inline for any reason. gcc lists reasons why it might not inline a function, but exception throwing is not among them. Also, the option -Winline will cause the compiler to issue a warning if it can't inline a function that you marked as inline. You can try that and see if you are doing anything to prevent inlining.

这篇关于C ++异常会阻止内联函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆