Skip to content
Snippets Groups Projects
Commit 95aef01a authored by kaldoran's avatar kaldoran Committed by Adrien Béraud
Browse files

Pht : Fix out of range in isActiveBit function

parent d2ccde48
No related branches found
No related tags found
No related merge requests found
...@@ -52,8 +52,12 @@ struct Prefix { ...@@ -52,8 +52,12 @@ struct Prefix {
* @param pos : Pos of the needed bit * @param pos : Pos of the needed bit
* @return : true if the bit is at 1 * @return : true if the bit is at 1
* false otherwise * false otherwise
* @throw out_of_range Throw out of range if the bit at 'pos' does not exist
*/ */
bool isActiveBit(size_t pos) const { bool isActiveBit(size_t pos) const {
if ( pos >= size_ )
throw std::out_of_range("Can't detect active bit at pos, pos larger than prefix size or empty prefix");
return ((this->content_[pos / 8] >> (7 - (pos % 8)) ) & 1) == 1; return ((this->content_[pos / 8] >> (7 - (pos % 8)) ) & 1) == 1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment