Debashish Samantaray
Debashish Samantaray

Reputation: 33

Finding the key respective values in bimap

I have a bimap

boost::bimap<std::string, vector<string>> mymap;

I have to seach for the vector mapped to the exact key type i.e std::string. Getting some problem while printing the right part which exactly mapped to right string.

Something like below

auto it = mymap.left.find(input):

After finding the it I am able to print it->first;

I am facing problem in printing the second part i.e vector<string> which is exactly mapped to the it->first.

Please suggest.

Upvotes: 1

Views: 50

Answers (1)

sehe
sehe

Reputation: 393114

It's in it->second;

You'd print it in any way you normally would print the vector, e.g.

for(auto& el : it->second)
    std::cout << el << "\n";

Or

stc::copy(it->second.begin(),
     it->second.end(),
     std::ostream_iterator<std::string>(std::cout, "\n"));

Upvotes: 2

Related Questions