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

  • SEARCH
  • Home
  • 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 8984329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:04:38+00:00 2026-06-15T21:04:38+00:00

According to http://www.cplusplus.com/reference/vector/vector/operator=/ I understand that we can use the ‘=’ operator for assignment

  • 0

According to http://www.cplusplus.com/reference/vector/vector/operator=/ I understand that we can use the ‘=’ operator for assignment of vectors. But running the following code, I get an error. What is going wrong?

Code:

 void checkFunction(map<string, vector<string> > foo){
     vector<string> bar;     
     bar = foo.find("ABC");
     }

Error :

error: no match for ‘operator=’ in ‘bar = foo.std::map<_Key, _Tp, _Compare, _Alloc>::find [with _Key = std::basic_string<char>, _Tp = std::vector<std::basic_string<char> >, _Compare = std::less<std::basic_string<char> >, _Alloc = std::allocator<std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > > >, std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > > >, key_type = std::basic_string<char>](((const std::map<std::basic_string<char>, std::vector<std::basic_string<char> > >::key_type&)(& std::basic_string<char>(((const char*)"PAR"), ((const std::allocator<char>&)((const std::allocator<char>*)(& std::allocator<char>())))))))’

std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::basic_string<char>, _Alloc = std::allocator<std::basic_string<char> >]
std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::basic_string<char>, _Alloc = std::allocator<std::basic_string<char> >, std::vector<_Tp, _Alloc> = std::vector<std::basic_string<char> >]
std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_CharT>) [with _Tp = std::basic_string<char>, _Alloc = std::allocator<std::basic_string<char> >, std::vector<_Tp, _Alloc> = std::vector<std::basic_string<char> >]
  • 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-06-15T21:04:40+00:00Added an answer on June 15, 2026 at 9:04 pm

    The map::find method returns an iterator pointing at the element you search for (stored in a std::pair containing the key as first and value as second).

    To access the vector pointed at by the iterator, you need to dereference it and fetch the second element of the pair.

    void checkFunction(map<string, vector<string> > foo){
        typedef map<string, vector<string> > map_t;
    
        map_t::const_iterator i = foo.find("ABC");
        if (i == foo.end()) {
            // element not found!
        }
    
        vector<string> bar(i->second);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

according to this site http://www.cplusplus.com/reference/std/functional/unary_function/ this code should work #include <iostream> #include <functional> using
So according to the link here: http://www.cplusplus.com/reference/algorithm/max_element/ , the max_element function is O(n), apparently
According to http://www.rebol.com/docs/core23/rebolcore-15.html You can use change/part to parse and replace but that doesn't
According to http://www.cplusplus.com/reference/clibrary/ctime/time_t/ time_t is the number of seconds since midnight 1/1/1970 UTC. So
According to this documentation http://www.cplusplus.com/reference/clibrary/ctime/time/ for time(NULL) If the function could not retrieve the
According to the text at http://www.cplusplus.com/reference/string/string/ , string library in C++ is a class,
http://www.cplusplus.com/reference/algorithm/for_each/ Unary function taking an element in the range as argument. This can either
According to http://www.cplusplus.com/reference/stl/deque/push_front/ x is Value to be copied to the new element. T
Is the following code correct? char mychar = 200; printf(%x, mychar); According to http://www.cplusplus.com/reference/clibrary/cstdio/printf/
According to this http://www.cplusplus.com/reference/clibrary/csignal/signal.html SIGINT is generally used/cause by the user. How do i

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.