#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <vector>

int main()
{
    using namespace std::placeholders;

    std::map<std::string, int> karta;
    std::vector<std::string> goroda{ "foo", "bar", "foo" };

    std::for_each(goroda.begin(), goroda.end(), std::bind(
        static_cast<
            std::pair<decltype(karta)::iterator, bool>
            (decltype(karta)::*)(const decltype(karta)::key_type&, decltype(karta)::mapped_type&&)>
                (&decltype(karta)::insert_or_assign),
        std::ref(karta),
        _1,
        std::bind(
            std::plus<decltype(karta)::mapped_type>(),
            1,
            std::bind(
                static_cast<decltype(karta)::mapped_type&(decltype(karta)::*)(const decltype(karta)::key_type &)>
                (&decltype(karta)::operator[]),
                std::ref(karta),
                _1))
    ));
    std::cout << "foo: " << karta["foo"] << "\nbar: " << karta["bar"] << '\n';
    
    return EXIT_SUCCESS;
}