Boost logo

Boost :

Subject: Re: [boost] Is there a special reason to use inline before template functions?
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2008-12-08 15:33:58


Andrey Semashev wrote:
> > Some compilers disable default inlining under certain
configurations.
> > GCC has -fno-default-inline for instance. Some libraries might
> > explicitly put inline there to support these configurations.
>
> Well, I guess the one who uses such configurations does so for a
reason
> (i.e. he wants these functions *not* to be inline), so the keyword
still
> doesn't make sense to me. Unless it works around some compiler bug...

Thanks for the answers. So my conclusion is:
- the inline keyword for template functions is only required for
performance reasons.
- My expectation that current compilers know better than me when to
inline a function may be too optimistic.

My problem is that some code in numeric-bindings uses the inline keyword
for template functions quite inconsistently. I had hoped that the inline
keyword itself is superfluous, so that I can simply remove it without
any further thought. I will now try to use the inline keyword for
obvious cases like simple forwarders, and remove it from more complex
template functions where I'm unable to decide whether it is a good idea
to inline the function. My reason for this is that I don't want to think
too much about possible performance impact of inlining, but don't want
to deviate too much from the common practice of other boost-libraries.

Regards,
Thomas


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk