I am setting up an unordered_map, in which the key is an enum of Direction defined as:
enum Direction : uint16_t {
North = 1 << 0,
East = 1 << 2,
South = 1 << 3,
West = 1 << 4,
None = 1 << 5,
};
The goal is to check if at least 2 of these flags are set, but up to n flags set.
With my enum defined above, I attempt to create a number of unordered_maps
std::unordered_map<Direction, std::vector<Tile*>>* groundTiles;
std::unordered_map<Direction, std::vector<Tile*>>* northEastHillTiles;
std::unordered_map<Direction, std::vector<Tile*>>* southEastHillTiles;
std::unordered_map<Direction, std::vector<Tile*>>* platformTiles;
std::unordered_map<Direction, std::vector<Tile*>>* wallTiles;
I initialize them as
groundTiles = new std::unordered_map<Direction, std::vector<Tile*>>();
groundTiles->insert_or_assign(Direction::None, std::vector<Tile*>());
groundTiles->insert_or_assign(Direction::East, std::vector<Tile*>());
groundTiles->insert_or_assign(Direction::West, std::vector<Tile*>());
groundTiles->insert_or_assign((Direction)(Direction::East|Direction::West),std::vector<Tile*>());
and so on for the other sets
However, when I try to pull a Tile from the ground ( or any other set ) I cannot check if at least Direction::East and Direction::West are set. I have tried:
Tile* westAndEastCapped = southEastHillTiles->at((Direction)(Direction::West | Direction::East)).at(0);
But it seems to just default to the Direction::East set.
How can I select a tile from an unordered_map, with BOTH East and West flags set, and no others?