A frustrating 4 hours. I wanted to do something with an array of function pointers similar to something that was done in RomiChess. So I looked in RomiChess to see how it was done. However, Romi is in C and this engine is in C++ so it would not work. I got errors that constantly changed with every change that was tried. So I looked in my ancient C++ primer and it still didn't work. Then I went online to Stack Overflow and found lots of examples but there was always something wrong. I started to hit things (soft things like the arm of my chair), lol. Anyway, I did find an example that was exactly what I was trying to do and it worked! But it was done in a way that I had never seen before. So I thought I'd share it.
typedef void MGt(threadS *, moveU *); // This seems to be another way to declare a prototype.
MGt WPf, WNf, WBf, WRf, WQf, WKf, BPf, BNf, BBf, BRf, BQf, BKf; // This is like creating 12 functions like creating 12 variables.
MGt *MGf[12] = { WPf, WNf, WBf, WRf, WQf, WKf, BPf, BNf, BBf, BRf, BQf, BKf }; // Then create the 12 poiters.
// Then what, specify the actual function code?
void WPf(threadS *t, moveU *m) {}
void WNf(threadS *t, moveU *m) {}
void WBf(threadS *t, moveU *m) {}
void WRf(threadS *t, moveU *m) {}
void WQf(threadS *t, moveU *m) {}
void WKf(threadS *t, moveU *m) {}
void BPf(threadS *t, moveU *m) {}
void BNf(threadS *t, moveU *m) {}
void BBf(threadS *t, moveU *m) {}
void BRf(threadS *t, moveU *m) {}
void BQf(threadS *t, moveU *m) {}
void BKf(threadS *t, moveU *m) {}
// Then actually call the function
MGf[typ](t, &t->moves[t->ply]);
This looked very strange but the longer I looked the more I liked it.