Subject: Re: [boost] inline specifier within in class definition
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2009-05-04 09:59:58
Thomas Klimpel wrote:
> Mateusz Loskot wrote:
>> However, I've not found clear answer in that thread.
> Strange. I assume your question is "Why are some static member
> functions defined within class definitions specified with inline
> keyword?" and the answer is "The only reasons for this is to try to
> influence the inlining behavior of the compiler." (+copy&paste from
> existing code...)
> This is what I call a clear answer.
I understand it but isn't enough to define such member function
within class definition? It should be, according to what the C++
> The questions
> 1) Whether it is necessary to try to influence the inlining behavior
> of the compiler, and
> 2) Whether the inline keyword actually does
> influence the inlining behavior of the compiler
> may be related questions, but the fact the some of us have a hard
> time believing the answers to these questions doesn't make the answer
> to the initial question less clear.
I'm just trying to confront specification of inline behavior in the
standard with use of in-class definition of member functions together
with inline keyword I see in Boost code.
>> Looks like it's a kind of mix of historical relict of old
>> pre-standard habits
> I can't remember any reference to pre-standard habits in the answers
> in that thread. You probably mean compilers with poor optimization
> capabilities, but "pre-standard" does say something completely
I meant pre-standard as old compilers like Visual C++ <= 6.0 or old
line of GCC 2.x.
>> with disbelief today compilers are able choose right
> In my impression, this question wasn't settled in that thread.
> However, the supporters of the "you sometimes have to help the
> compiler" opinion were actually more willing to present experimental
> evidence than the people who thought this was superstition.
> The problem of this is that you don't end up with a definite answer
> when to use the inline keyword (I guess you were hoping for "never
> use the inline keyword unless explicitly required"), and that the
> mere presence of some (superfluous?) inline keywords will make more
> superfluous inline keywords appear by "copy&paste".
Well, sort of, yes.
-- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org