samedi 25 mars 2023

c++ map is empty despite initialisation [closed]

Hi so I have the following map declaration

std::map<std::array<int, 2>, std::vector<totalState>, ArrayCompare> totalResponse;

where total state is a custom struct array compare is the custom comparator function

In my cpp file class constructor I initialise the map like so

playerState::playerState(GameObject* theEnemy, GameObject* thePlayer) {
        playerForwardState = still;
        playerSideState = still_side;
        playerTrack = thePlayer;
        enemy = theEnemy;
        temporaryState = new totalState();
        currentState = new totalState();
        currentState->forwardResponse = currentStateForward::non_forward;
        currentState->sidewardsResponse = currentStateSideward::non_side;
        setInitialPosition();
        oldPosition = thePlayer->GetTransform().GetPosition();
        totalResponse = {
         { {0, 0},  },
         { {0, 1},  },
         { {0, 2},  },
         { {0, 3},  },
         { {0, 4},  },
         { {1, 0},  },
         { {1, 1},  },
         { {1, 2},  },
         { {1, 3},  },
         { {1, 4},  },
         { {2, 0},  },
         { {2, 1},  },
         { {2, 2},  },
         { {2, 3},  },
         { {2, 4},  },
         { {3, 0},  },
         { {3, 3},  },
         { {3, 4},  },
         { {4, 0},  },
         { {4, 3},  },
         { {4, 4},  },
         { {5, 0},  },
         { {5, 3},  },
         { {5, 4},  }
        };
    }

the issue is when I run the code the map is empty could an issue with the array compare lead to this? thanks for any help!

Aucun commentaire:

Enregistrer un commentaire