- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
If you have a method and you want to give the compiler a hint that it is a good idea to inline it, you currently have 2 solutions. The first one is to define the methods when you declare your class:
class Vector { private: double* data_; double* size_; double* capacity_; public: double& operator[](int k) { return data_; } ... }
As this method might reduce readability, another solution is to use the inline keyword and define the method out of class:
class Vector { private: double* data_; double* size_; double* capacity_; public: inline double& operator[](int k); ... } double& Vector::operator[](int k) { return data_; }
This makes the code more readable (at least I prefer it). Reading my STL implementation, I found that they use a mix of the two. Some methods (those which I think should really be inlined) are defined in the class, and others are defined out of class with the inline keyword. The file also begins with a commented declaration of the class.
So my question is the following. Do Intel compilers are more likely to inline a member function that is declared inside the class than a member function declared out of class with the inline keyword?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> So my question is the following. Do Intel compilers are more likely to inline a member function that is declared inside the class than a member function declared out of class with the inline keyword?
The answer is: No, except that sometimes developers tend to use inline keyword for the larger functions, and when a function is larger it is less likely to get inlined
_Kittur.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Faça compiladores da Intel são mais propensos para inline uma função membro que é declarada dentro da classe do que uma função de membro declarado fora da classe com a palavra-chave inline.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI Cardin!
I've to find someone who can decipher your response! Thanks for the response and hopefully I should find out more on that..
_Kittur
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page