是否可以在switch语句中使用可变大小的常量表达式数组,以使每个arri都是case?或者if语句是唯一的解决方案。constexpr int arr[] = {35, 2, 234, 42, ..., N}; // <------ Random ints
constexpr int size = sizeof(arrThats why I was looking for a workaround where the switch accep
const instruction HALT{0x76, 1};我最初的计划是使用这个结构来定义所有的操作码,因为我的印象是const比#然而,这似乎不适用于开关语句,正如我最初的意图。下面的代码不会编译,Visual给出了错误"case表达式不是常量“。switch (next_instruction) { // next_instruction is an int parsed from a file
case HALT.opcod