Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Class templates and inlining (OT)

Author: Sune Fischer

Date: 15:17:29 12/23/02

Go up one level in this thread


On December 23, 2002 at 18:07:35, David Rasmussen wrote:

>On December 23, 2002 at 17:58:22, Sune Fischer wrote:
>
>>On December 23, 2002 at 17:38:39, David Rasmussen wrote:
>>
>>>There are several possibilities:
>>>1. MSVC6 is not the most compliant compiler on earth, so don't expect anything
>>>2. Maybe you are using this the wrong way? If you wrap things in a class, you
>>>will have to explicitly give the type argument when you use the static member
>>>functions:
>>>
>>>	int c=CUtil<int>::Max(a,b);
>>>
>>>Which is maybe not quite what you wanted. But that what you made :)
>>>You might want to wrap the functions in a namespace instead.
>>
>>Yes, I looked over the STL, and I think I prefer the namespace, although that is
>>cumbersome in its own way.
>>
>
>Cumbersome how? A namespace should be used whenever it is the best solution. A
>class is a namespace (a restricted one), a namespace is not a class. You can do
>almost anything with a namespace.


I just meant by the look of it:

namespace std {
template<class InIt, class Fun>
    Fun for_each(InIt first, InIt last, Fun f);
template<class InIt, class T>
    InIt find(InIt first, InIt last, const T& val);
template<class InIt, class Pred>
    InIt find_if(InIt first, InIt last, Pred pr);
template<class FwdIt1, class FwdIt2>
    FwdIt1 find_end(FwdIt1 first1, FwdIt1 last1,
        FwdIt2 first2, FwdIt2 last2);
template<class FwdIt1, class FwdIt2, class Pred>
    FwdIt1 find_end(FwdIt1 first1, FwdIt1 last1,
        FwdIt2 first2, FwdIt2 last2, Pred pr);
template<class FwdIt1, class FwdIt2>
    FwdIt1 find_first_of(FwdIt1 first1, FwdIt1 last1,
        FwdIt2 first2, FwdIt2 last2);
template<class FwdIt1, class FwdIt2, class Pred>
    FwdIt1 find_first_of(FwdIt1 first1, FwdIt1 last1,
        FwdIt2 first2, FwdIt2 last2, Pred pr);
template<class FwdIt>
    FwdIt adjacent_find(FwdIt first, FwdIt last);
template<class FwdIt, class Pred>
    FwdIt adjacent_find(FwdIt first, FwdIt last, Pred pr);
    size_t count(InIt first, InIt last,
        const T& val, Dist& n);
....

isn't that cumbersome to look at ;)
I just thought it would "look better" to only have the template keyword once,
but I guess that's just me being a newbie, again ;)

>When I directed you to comp.lang.c++, it was not because I thought you were
>off-topic (I started the Two Towers thread :), but because I thought you would
>get better help there. CCC is good for chess programming questions, but the
>level of language knowledge isn't especially high in here.

But there is a good balance here between speed and style, many post assembler
code and such. I have tried a few questions in c.l.c++ and I always think the
thread turns into something else, like "you shouldn't be inlining because that
is bad style" or something to that effect.
Try telling them you have a goto in a function and you will get flamed by 15
angry posters telling you that is crap code! ;-)

-S.



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.