Skip to content
New issue

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

Handled SIZE == 0 edge cases #501

Merged
merged 1 commit into from
Jan 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions include/etl/bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ namespace etl
size_t index;
element_t mask;

if (SIZE == 1)
if (SIZE == 0) {
return false;
}
else if (SIZE == 1)
{
index = 0;
mask = element_t(1) << position;
Expand Down Expand Up @@ -297,7 +300,10 @@ namespace etl
size_t index;
element_t bit;

if (SIZE == 1)
if (SIZE == 0) {
return *this;
}
else if (SIZE == 1)
{
index = 0;
bit = element_t(1) << position;
Expand Down Expand Up @@ -453,7 +459,11 @@ namespace etl
size_t index;
element_t bit;

if (SIZE == 1)
if (SIZE == 0)
{
return *this;
}
else if (SIZE == 1)
{
index = 0;
bit = element_t(1) << position;
Expand Down Expand Up @@ -494,7 +504,12 @@ namespace etl
size_t index;
element_t bit;

if (SIZE == 1)

if (SIZE == 0)
{
return *this;
}
else if (SIZE == 1)
{
index = 0;
bit = element_t(1) << position;
Expand Down Expand Up @@ -580,7 +595,11 @@ namespace etl
size_t index;
size_t bit;

if (SIZE == 1)
if (SIZE == 0)
{
return ibitset::npos;
}
else if (SIZE == 1)
{
index = 0;
bit = position;
Expand Down Expand Up @@ -692,7 +711,10 @@ namespace etl
//*************************************************************************
ibitset& operator<<=(size_t shift)
{
if (SIZE == 1)
if (SIZE == 0) {
return *this;
}
else if (SIZE == 1)
{
pdata[0] <<= shift;
}
Expand Down Expand Up @@ -720,7 +742,10 @@ namespace etl
//*************************************************************************
ibitset& operator>>=(size_t shift)
{
if (SIZE == 1)
if (SIZE == 0) {
return *this;
}
else if (SIZE == 1)
{
pdata[0] >>= shift;
}
Expand Down