Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Class templates and inlining (OT)

Author: Sune Fischer

Date: 13:55:26 12/23/02

Go up one level in this thread


On December 23, 2002 at 16:43:20, Russell Reagan wrote:

>On December 23, 2002 at 16:20:48, Sune Fischer wrote:
>
>>I want to do Swap, Max, Sort and all that the smart way, no macros!
>
>The STL has a swap() and a sort() that work on any type.

Ok, I will check them out, but I don't want some slow non-inlined junk code of
course. Swap must be inlined, it runs a million times a second.

>>Different question, even more serious.
>>How tha' heck do I inline functions in C++?
>>The only way to inline is to write the whole function inside the header
>>file in the class, why is that? Isn't there a way to just have the prototype in
>>the class, and have the inlined function written in the cpp file?
>>What good is cpp files then, seems I only ever need headers???
>
>You have to make the function you want inlined viewable by the place you are
>inlining it. If it's in another source file, it's not viewable *from the file
>that you are in* (unless you #include it, hince why writing it in an include
>file works).

If I start including source files in source files I get a dozen other errors,
however both functions are members of the same class, just not written in the
same file.

-S.
>Russell



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.