Author: Daniel Clausen
Date: 09:47:21 11/27/03
Go up one level in this thread
Hi Russell!
On November 26, 2003 at 23:05:46, Russell Reagan wrote:
>On November 26, 2003 at 17:30:03, Daniel Clausen wrote:
>
>>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];
>
>The advantage of the code that I posted was that you only had to write one
>function, but you had to create two ColorTraits structs. In other words, you
>specified the small portions of the function that would differ in the structs,
>then write one function.
Yes I understood that.
What I'm trying to achieve in the end is something like that:
template <Color c> myFunction(void)
{
[...]
uint64_t bb = AttackTable::ColorTraits<c>::pawnAT[42];
[...]
}
I guess I could use that:
uint64_t bb;
if(c == White) bb = AttackTable::whitePawnAT[42]...
else bb = AttackTable::blackPawnAT[42]...
and the if-statement there would be optimized away anyway since 'c' is constant
in a specific instance. But I try to avoid this if-statement. Maybe that doesn't
work though?
Sargon
This page took 0.01 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.