I'm trying to build a SNES emulator in C++, using this tutorial as inspiration re: how to set up my data structures. In the video, he creates an array of structs (representing CPU instructions) and initializes it using an initializer list. However, when I try to do the same using a map<>
, I get an error reporting that the compiler "could not convert" my initializer list to a map. What am I doing wrong? Below is my code; for context, I have typedef'd unsigned char
to byte
.
struct instruction {
byte (SNES_CPU::*op)(void) = nullptr;
byte (SNES_CPU::*mode)(void) = nullptr;
byte cycles = 0;
};
using cpu = SNES_CPU;
std::map<byte, struct instruction> ops = {
{0x69, {&cpu::ADC, &cpu::IMM8, 2}},
{0x6D, {&cpu::ADC, &cpu::ABS8, 4}}
};
Additionally, when I try to set individual entries in the map to a struct instruction
with an initializer list, it gives me a similar error.
ops[0x69] = {&cpu::ADC, &cpu::IMM8, 2};
I'm working on Raspbian, and compiling with G++ 8.3.0.