Problems with lambdas and references

This commit is contained in:
Kayne Ruse
2014-11-26 03:05:40 +11:00
parent bd3838a04e
commit fdaae0e8f2
21 changed files with 70 additions and 26 deletions
+3 -2
View File
@@ -33,7 +33,8 @@
int RoomManager::Create(std::string roomName) {
std::cout << "Create-1" << std::endl;
//create the room
RoomData* newRoom = &elementMap[counter]; //implicitly constructs the element
elementMap.emplace(counter); ////explicitly constructs the element
RoomData* newRoom = &(elementMap.find(counter)->second);
std::cout << "Create-2" << std::endl;
newRoom->SetRoomName(roomName);
std::cout << "Create-3" << std::endl;
@@ -59,7 +60,7 @@ void RoomManager::UnloadAll() {
elementMap.clear();
}
void RoomManager::UnloadIf(std::function<bool(std::pair<const int,RoomData>)> fn) {
void RoomManager::UnloadIf(std::function<bool(std::pair<const int,RoomData>&)> fn) {
std::map<int, RoomData>::iterator it = elementMap.begin();
while (it != elementMap.end()) {
if (fn(*it)) {