for (std::size_t iter = 0; iter != m_queryMap.size(); ++iter)
{
    // note here, line = iter + 1;
    std::set<std::size_t> lineBuck;
    lineBuck.insert(iter + 1);
    const std::vector<std::string> 
        &bucket = m_queryMap.at(lineBuck);
}

where

std::map<std::set<std::size_t>, std::vector<std::string> > m_queryMap; // storing each line of input 
                                                                       // crossed with the line number as its key

yup, I know I could've used std::size_t only as the key for the map.
but it was said in the book that:

We'll use a set to hold the line numbers on which each word in the input appears. Using a set guarantees that each line
will appear only once and that the line numbers will be stored in ascending order;

which what the keys of the map is exactly doing without the need of set, so it's kind of weird, but not only that, it give me hard time to access the respective element inside the map due to type conversion and out_of_range error; so how exactly the method that I could've have used?

been trying:

accessing through std::set<std::size_t> member that stored the value in-beforehand but then failed due to un-able to access it and having a hardtime with type conversion.

So you have a set that hold all of the line numbers a give word appears? Then you need to store all of the words in that text with thier related set in another container? If that that case the map should be keyed by the word and the set should be the data.

This article has been dead for over six months. Start a new discussion instead.