"直列&QUOT ;? [英] "inline"?

查看:55
本文介绍了"直列&QUOT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不清楚使用关键字内联...我相信你添加

当你在标题中实现函数时它会做一个函数

文件课程的存储地点...


但这就是全部吗?我错过了什么?


如果这就是全部,那么为什么Bjarne甚至不愿意将它添加到

语言中?


如果不是全部,我还可以用内联做什么?

解决方案

>我不清楚使用关键字内联...我相信你添加

当你在存储类的头文件中实现函数时,它会执行一个函数。 。
如果不是全部,我还可以用内联做什么?




内联意味着函数体将被复制到任何地方函数是被调用的
,所以不会花费调用函数的时间。它可以在你不间断调用相同功能的循环中使用

有用,或类似

......


Marko Becirevic写道:

我不清楚使用关键字内联...我相信你添加
它当你在存储类的头文件中实现函数时执行一个函数...

如果不是全部,那么我还能做什么?内联 ?



内联意味着函数体将被复制到调用函数



的任何地方,因此不会花费调用函数的时间。它可以在你不间断调用相同功能的循环中有用,或类似
......




更改将 ;到可能。 inline是对编译器的建议,而不是授权。


Marko Becirevic写道:

我不清楚使用关键字内联...我相信你添加
当你在存储类的头文件中实现函数时它会执行一个函数...


如果不是全部,我还可以用内联做什么?



内联意味着函数体将会被复制到调用函数的任何地方,因此不会花费调用函数的时间。它可以在循环中非常有用,你可以不停地调用相同的函数,或类似
的东西......




好吧,关闭。 ;-)


这是*建议*编译器内联函数(只是如何使用
积极地给定编译器将承认此类请求通常是

可由编译器特定选项控制)。


如上所述,内联通常很有价值的一个案例是

函数在紧密循环中调用;另一个是当一个小函数在整个代码中被频繁调用时 - 它的代码很小

很小,标准调用序列会比
更贵
代码本身。


除了紧密循环和简单函数之外,内联是

类型的优化,通常只应该使用当通过性能分析发现性能

瓶颈时。


还要注意内联递归函数(是否递归

是直接的还是间接的)显然是不走。


HTH,

--ag


-

Artie Gold - 德克萨斯州奥斯汀

哦,对于常规老垃圾邮件的美好时光。


I am not clear with the use of the keyword inline... I believe you add
it do a function when you implement the function inside the header
file where the class is stored...

But is that all? What am I missing?

If that''s all, then why did Bjarne even bother adding it to the
language?

If that''s not all, what else can I do with "inline"?

解决方案

> I am not clear with the use of the keyword inline... I believe you add

it do a function when you implement the function inside the header
file where the class is stored... If that''s not all, what else can I do with "inline"?



Inline means that function body will be copied everywhere where function is
called, so the time for calling function will not be spent. It can be
usefull in loops where you non-stop call same function, or something like
that...


Marko Becirevic writes:

I am not clear with the use of the keyword inline... I believe you add
it do a function when you implement the function inside the header
file where the class is stored...

If that''s not all, what else can I do with "inline"?



Inline means that function body will be copied everywhere where function


is called, so the time for calling function will not be spent. It can be
usefull in loops where you non-stop call same function, or something like
that...



Change "will" to "may". inline is advice to the compiler, not a mandate.


Marko Becirevic wrote:

I am not clear with the use of the keyword inline... I believe you add
it do a function when you implement the function inside the header
file where the class is stored...



If that''s not all, what else can I do with "inline"?


Inline means that function body will be copied everywhere where function is
called, so the time for calling function will not be spent. It can be
usefull in loops where you non-stop call same function, or something like
that...



Well, close. ;-)

It''s a *suggestion* to the compiler to inline the function (just how
aggressively a given compiler will honor such request is often
controllable by compiler specific options).

One case in which inlining is often valuable is, as you''ve said, when a
function is called in a tight loop; another is when a small function is
called frequently throughout the code -- and its code is sufficiently
small that the standard calling sequence would be more expensive than
the code itself.

With the exception of tight loops and trivial functions, inlining is the
sort of optimization that should usually be used only when a performance
bottleneck has been discovered through profiling.

Also be aware that inlining a recursive function (whether the recursion
is direct or indirect) is, obviously, a `no-go''.

HTH,
--ag

--
Artie Gold -- Austin, Texas
Oh, for the good old days of regular old SPAM.


这篇关于"直列&QUOT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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