I want to create std::unordered_map<char, std::size_t> , which for each added character will store the number under which it was added (starting from 0, the added characters are unique). I think to write
std::unordered_map<char, std::size_t> map; for (auto character : characters) map[character]=map.size(); Would it be a UB ? Is there a better way?
map[character] = 0; map[character] = map.size() - 1map[character] = 0; map[character] = map.size() - 1- vegorov