This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::pow implementation


Alexandre Oliva <aoliva@redhat.com> writes:

| On Jul 30, 2003, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
| 
| > | Because (1) inline is implicit in C++,
| 
| > No, that is *your* invention.  Inline is NOT implicit.
| 
| For a member function defined inside the class body, it is.
| [dcl.fct.spec]/3  Sorry that I wasn't clear.

  A function defined within a class definition is an inline
  function. The inline specifier shall not appear on a block scope
  function declaration. 

only the *keyword* is implicit.  But then, that is a _deliberate_
decision. 

The *fact* is that when inline was originally introduced in C++, the
only way to declare a function to be inline is

  1) have it to be a member function
  2) define it within the class definition.

Again, quoting "The Design and Evolution of C++"

  In C with Classes, only member functions could be inlined and the
  only way to request a function to be inlined was to place its body
  within the class declaration.  For exemple:

   class stack {
       /* ... */
     char pop()
     { if (top <= min) error ("stack underflow");
        return *--top;
     }

  The fact that this made class declarations messier was observed at
  the time and seen as good thing in that it discourages overuse of
  inline functions.  The "inline" keyword and the ability to inline
  nonmember functions came with C++.  [...]


Please, do give inline its original and obvious meaning.

| > Only because you have decided to transmute the original meaning of C++.
| 
| I haven't chosen anything, I just quoted the C Standard.  It clearly
| calls for compiler's effort towards fast execution over inline
| substitution.  Compared with that, what you claim to be C++'s intended
| meaning (inline even if the resulting code is worse) seems as a very
| misguided idea.

It is a misguided idea for you only if you decide to ignore why inline.
I gave a quote of the purpose of inline in C++.  Let the programmer
make the choice.  Trust the programmer.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]