Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Colourspecific code (C++ and templates/traits)

Author: Sven Reichard

Date: 04:01:31 11/27/03

Go up one level in this thread


On November 26, 2003 at 17:30:03, Daniel Clausen wrote:

>Hi
>
>Russell's post (http://www.talkchess.com/forums/1/message.html?330142) made me
>think a little and I tried to make use of it in the following case:
>
>class AttackTable
>{
>   public:
>      static void init(void);  // Initializes all static arrays
>
>      static uint64_t whitePawnAT[64];
>      static uint64_t blackPawnAT[64];
>
>      ...
>};
>
>
>Using templates/traits, I would like to replace the call
>
>   uint64_t bb = AttackTable::whitePawnAT[42];
>
>with something like
>
>   uint64_t bb = AttackTable::ColorTraits<White>::pawnAT[42];
>
>I tried a bit but the stuff didn't even compile. :) Ideas? Comments? Shrieking
>epitaphs? Thanks!
>
>Sargon
>
>PS. I hope I don't overlook something stupid. If I do, my account got hacked and
>this post is not really from me. :)

Sargon,

One thing to keep in mind is that template instantiations are decided at compile
time. So you can't do anything like

void f(Color c)
{
  uint64_t bb = AttackTable::ColorTraits<c>::pawnAT[42];
}

However, I think that this was clear to you. Other than that, I can't see from
the code you posted what went wrong. Could you post or send the code you tried
to compile?

Sven.



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.