std::pow implementation
Martin Reinecke
martin@MPA-Garching.MPG.DE
Wed Jul 30 13:40:00 GMT 2003
Gabriel Dos Reis wrote:
> Martin Reinecke <martin@MPA-Garching.MPG.DE> writes:
>
> | This is certainly a valid point of view, but I think that C++, as it exists
> | at the moment, just _doesn't give_ the programmer the possibility of specifying
> | what exactly (s)he wants.
>
> But taking out the only lever the programmer currently has is even far
> worse.
Right, but that's exactly the dilemma with C++'s "implicit" inline:
if you want the compiler to _be able_ to inline a function, you should put
it in the class definition. But this implies an "inline" directive
which would more or less _force_ the compiler to always inline the code.
So, if inline was as strict as you'd like to see it, there would be no
way to tell gcc "here's a function that might be probably worthwhile to
inline". I could only say "inline this" or "don't inline".
This could change if gcc starts to inline functions across translation units,
but currently it doesn't (I believe).
> | I think it is not generally possible for a programmer to decide
> | whether a function should be inlined or not (see below).
>
> I reckon that there are conner cases that "inline" does not cover.
> But, I'm worrying about the common situations -- and those that ave
> been subject of PRs.
I've encountered the example I gave a few times in real-life code,
but in the frame of standard C++ nothing can be done about it, so
I cannot file a PR.
> However, in lieu of pragmas, I will point out that current C++
> gives the programmer means to express, in many corner cases, the
> intention of not inlining, by combining inline and noninline
> definitions and object functions.
You're right. It's not too beautiful and makes maintenance a bit harder,
but on the other hand it shouldn't happen too often.
Martin
More information about the Gcc
mailing list