If found templates very useful in Stockfish (yes, I admit, I've copied code from Stockfish: the word "template"), and I've googled to try to understand how they work. I'm not sure, but it seems they can't be used the way I'm trying to, but I don't quite understand why. If this is the case, I'd appreciate an advice on how to do it in a different way.
The code:
I have a CColor class, which defines an enum that I typedef as TColores:
Code: Select all
public:
static enum eColor
{
BLANCAS = 0,
NEGRAS = 1,
NEUTRAL = 2
};
typedef enum eColor TColores;
Code: Select all
template <CColor::TColores tColor>
inline void InsertarJugadasPeon(CJugada * pJug, const CCasilla & cDesde);
In the appropiate code file, I have the body of the function:
Code: Select all
template <CColor::TColores tColor>
inline void CPosicion::InsertarJugadasPeon(CJugada * pJug, const CCasilla & cDesde)
{
// Code here
}
When I compile (MS Visual Studio 2008 Express Edition) I get this error:
Code: Select all
Compilando...
casilla.cpp
globales.cpp
main.cpp
posicion.cpp
posicion_ataques.cpp
posicion_genmov.cpp
posicion_mover.cpp
reloj.cpp
sesion.cpp
wbii.cpp
busqueda.cpp
Generando código...
d:\proyectoschz\anubis\posicion_genmov.cpp(47) : fatal error C1001: Error interno en el compilador.
Archivo del compilador 'f:\dd\vctools\compiler\utc\src\p2\main.c[0x5111E0DB:0x00000030]', línea 182
Para solucionar este problema, intente simplificar o cambiar el programa en aquellas líneas próximas a las ubicaciones que se enumeran a continuación.
Elija el comando Soporte técnico en el menú Ayuda de Visual C++
o abra el archivo de ayuda de soporte técnico para obtener más información