(Segmentation fault) Error occurs while accessing the value associated with the key in the unordered map. Any pointers a where I am making the mistake?
Segmentation fault in the following snippet of code:
void read_mdl(const std::string& fname) {
        std::ifstream f(fname);
        std::unordered_map<int, std::vector<double>> pt_;
        while(f) {
            int xi = -1;
            int pa = 0;
            double score = -1;
            f >> xi >> pa >> score;
            if(xi == -1) { break; }
            std::unordered_map<int, std::vector<double>>::iterator it = pt_.find(pa);
            std::cout << xi << " " << pa << " " << score << std::endl;
            if (it != pt_.end()) {
                // Update from @Matthias247
                 auto a = pt_.insert(std::make_pair(pa, std::vector<double>(n_, 0)));
                 it = a.first;
            }
            (it->second)[xi] = score; // causing segmentation fault
        }
    }
 
    