0
votes

I get the following error at this line:

const short pcmSample = *reinterpret_cast<const short*>(*(buffer->index));

buffer is an object of class accumlator.

Here I am trying to convert a byte array into shorts. The code throws this runtime error and terminates.

class accumlator : public boost::circular_buffer<char>
{
  public:
    boost::circular_buffer<char>::iterator index;
};

i have initialized the iterator to point to begin of buffer

and index is a iterator to circular buffer.

boost::cb_details::iterator::reference boost::cb_details::iterator::operator*() const [with Buff = boost::circular_buffer, Traits = boost::cb_details::nonconst_traits >, boost::cb_details::iterator::reference = char&]: Assertion `m_it != 0' failed.

i have even tracked this to the file boost/circular_buffer/detail.hpp

the assert condition checks - if iterator is pointing to end. if it is pointing to end then it throws the assert.

Thanks in advance.

1
I indented, capitalized and fixed you question. Please remember that the more effort you put in your question, the more likely you will get an answer.ereOn
Thank u very much ereOn,i will definitely try to improve my questions representation.ken

1 Answers

1
votes

It seems you didn't assign index to a value. The operator* is doing a runtime check to make sure it's pointing to valid (non-0) value.