Re: How to issue a warning if a C++ template is defined as 'inline' or 'static'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 7 Oct 2024 at 17:38, Paul Smith <paul@xxxxxxxxxxxxxxxxx> wrote:

> On Mon, 2024-10-07 at 16:33 +0100, Jonathan Wakely via Gcc-help wrote:
> > > - 'inline' just makes the template function more likely to be
> > > inlined, but it is not required in a header file, like it is
> > > usually required for normal functions in order to prevent
> > > redefinition errors.
> >
> > Right
>
> Isn't it more precise to say, it's not needed inside a class or struct
> definition?  If you have a free method


"free method" is an oxymoron. In other languages "method" generally means
the same as "member function" in C++, so a "free method" is a non-member
member function :-)
C++ doesn't use the word "method" though, it calls them member functions.



> in a header file you still need
>
to declare it to be inline, to avoid redefinition issues.
>

Not if it's a function template, because like inline functions they're
allowed to have multiple definitions (as long as the definitions are
identical).



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux