map<term_id, map<pair<document_id, positions_idx>> inverted_index;
Think you also meant to remove the pair in map<pair>?