2008年10月14日 星期二

inline keyword

Sometime in the late 1980s inline was a big shot. Today the best thing to do about this keyword is ignore it completely. Chances are high that your compiler and linker are smart enough to figure out by themselves which functions are better candidates for inlining and which ones aren't. Explicit inline declarations thus merely get in the compiler and linker's way. [ref]

整段話的意思呢,就是不需要去刻意的加入inline keyword,完全由complier幫你做最佳化,因為你加入inline keyword,還是由complier來決定要不要使用inline。

如果有考慮要讓complier來做implicit inline的話,必需要把你的function定義寫在.h檔 (class body)裡,如果寫在cpp的話,implicit inline不會有作用。




References
--------------------------------------
1. 30 C++ Tips in 30 Days: Tip # 3 inline Do's and Don'ts

沒有留言:

LinkWithin

Related Posts with Thumbnails