Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7496887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:50:10+00:00 2026-05-29T18:50:10+00:00

I have a fairly simple problem. I’m trying to make a function that accepts

  • 0

I have a fairly simple problem. I’m trying to make a function that accepts a map by reference and iterates through the keys of the map.

#include <map>
#include <string>
#include <sys/types.h>

using namespace std;

void update_fold_score_map(string subfold,
                           int32_t index,
                           int32_t subfold_score,
                           map<string, int32_t> &fold_scores){
  for(map<string, int32_t>::iterator i = fold_scores.begin();
      i != fold_scores.end();
      i ++){
    string current_substring;
    string fold;
    fold = (*i);
    current_substring = fold.substr(index, subfold.size());

    if (current_substring == subfold){
      if (fold_scores[fold] < subfold_score){
        fold_scores[fold] = subfold_score;
      }
      return;
    }
  }
}
int main(){
  return 0;
}

But, I’m getting an error at the line “fold = (*i);” which states:

compilemap.cpp:16:15: error: no match for ‘operator=’ in ‘fold = i.std::_Rb_tree_iterator<_Tp>::operator* [with _Tp = std::pair<const std::basic_string<char>, int>, std::_Rb_tree_iterator<_Tp>::reference = std::pair<const std::basic_string<char>, int>&]()’
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:50:12+00:00Added an answer on May 29, 2026 at 6:50 pm
    fold = (*i); // <- here
    

    fold is of std::string type; whereas (*i) is of map<string, int32_t>::value_type type, which happens to be std::pair<const string, int32_t>.Obviously, you cannot assign later to the former.

    What you probably want to do, is to

    fold = i->first; // which extracts "key" from the std::map<>::iterator
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is fairly simple. I have table sets that store product sets (more
I have a fairly simple question that has me stymied. I am trying to
I have a fairly simple call I'm trying to make to a database. I
I have a fairly simple sync problem. I have a table with about 10
I have a fairly simple const struct in some C code that simply holds
I have a fairly simple python loop that calls a few functions, and writes
I have fairly simple problem but I can not think of the simple solution.
This seems like a fairly simple problem to me but I have been having
I have a fairly simple bash shell scripting problem. I want to sed a
I have a fairly simple Psake build script (default.ps1) that calls Invoke-Psake from within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.