I want to use the std::fill function from the algorithm library to fill in '-' in the second part of the pair. Is this possible to achieve? Would be very grateful to anyone who provides me a solution or simply tells me this isn't possible.
#include <algorithm>
#include <map>
int main(){
std::map<int, unsigned char> board(10);
//What I want the std::fill to do the equivalent of
for (auto& cell : board) {
cell.second = '-';
}
//What I've tried:
std::fill(board.begin(), board.end(), [&](auto &pair){pair.second = '-';});
}
Aucun commentaire:
Enregistrer un commentaire