We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
block_queue中将m_front初始化为-1,也就是说front是指向队头的前一个位置,则访问的时候应该将front进行(front + 1) % m_maxsize,源代码的bool block_queue<T>::front(T& value)写错了,然后从一个简单的测试也可以看出这里存在问题,测试代码如下:
(front + 1) % m_maxsize
bool block_queue<T>::front(T& value)
int main() { block_queue<int> q; q.push(3); int a = 10; q.front(a); cout << a << endl; return 0; }
输出的结果应该为3,但实际并不是
The text was updated successfully, but these errors were encountered:
????
Sorry, something went wrong.
block_queue中将m_front初始化为-1,也就是说front是指向队头的前一个位置,则访问的时候应该将front进行(front + 1) % m_maxsize,源代码的bool block_queue<T>::front(T& value)写错了,然后从一个简单的测试也可以看出这里存在问题,测试代码如下: int main() { block_queue<int> q; q.push(3); int a = 10; q.front(a); cout << a << endl; return 0; } 输出的结果应该为3,但实际并不是
确实,需要+1再取出,改成这样value = m_array[(m_front+1)%m_max_size];
No branches or pull requests
block_queue中将m_front初始化为-1,也就是说front是指向队头的前一个位置,则访问的时候应该将front进行
(front + 1) % m_maxsize
,源代码的bool block_queue<T>::front(T& value)
写错了,然后从一个简单的测试也可以看出这里存在问题,测试代码如下:输出的结果应该为3,但实际并不是
The text was updated successfully, but these errors were encountered: