Invalid deque <T> subscript . Why am I getting this error?

930 views Asked by At

I am getting the execption error in the following piece of code. Any suggestions on what might be causing it ? Error : Invalid deque <T> subscript

typedef boost::shared_ptr<HistObj> shared_hist_def;
        typedef std::deque<shared_hist_def> vector_def;
        typedef boost::shared_ptr<vector_def> shared_vector_def;
        typedef boost::unordered_map<int,shared_vector_def> in_map_def;
        typedef boost::shared_ptr<in_map_def> shared_inner_map_def;

Domain::shared_hist_def& Domain::GetSpecificHistoricalTuple(const std::string& symb,const int& tframe,const int& val)
{
    Domain::shared_inner_map_def tshare = stat_History_base[symb];
    shared_vector_def tmp = tshare->at(tframe);
    try
    {
        Domain::shared_hist_def safe_tuple =  tmp->at(val);
        return safe_tuple;
    }
    catch (std::exception &ex)
    {
        std::string a = ex.what();
        __debugbreak();
    }
}

More information:

The above method is a static method. And the program is multithreaded.Any chance that this error occurs because multiple threads access it. I had that assumption but then think that function parameters above could never be the same at one time.

1

There are 1 answers

3
nullptr On

Your val parameter seems to be too high (greater or equal to the number of elements in the deque), or maybe it's negative.