Jump to content
  • Advertisement
Sign in to follow this  
dmatter

inlining a member call made from a reference

This topic is 4596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Will/can a compiler inline a member function if it is called from a reference to an object, like so:
template <class T>
class container
{
    T& ref; //reference to an object implementing 'void do_something()'

public:
    container(T& r) : ref(r) { }

    void make_call() { ref.do_something(); }
};
I would like to say that a general compiler would inline away make_call() and do_something() but I'm not convinced but I need to know now as this is performance crucial code i'm trying (*ahem, sniff*) to write. [smile] Thanks Dmatter P.S. I found it hard to find much on google, if anyone can offer any good search terms or a good linky, it'd be appreciated too.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Sure, it's not different from other inlinings...

Share this post


Link to post
Share on other sites
You could look at the disassembly you compiler generates rather than ask us. /FA family of switches for MSVC, -S for gcc. It probably is a better judge of what it will inline than humans.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!