Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Include/Common/BitFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class BitFlags
UnsignedInt toUnsignedInt() const noexcept
{
UnsignedInt val = 0;
const UnsignedInt count = min(m_bits.size(), sizeof(val) * 8);
const UnsignedInt count = (m_bits.size() < sizeof(val) * 8) ? m_bits.size() : sizeof(val) * 8;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, what do we need to do to get min into this file?

The new code is harder to read.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

If it is an issue that min() cannot be found, then there should be imho a macro for it in the case of minGW.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better alternative: #2183

for (UnsignedInt i = 0; i < count; ++i)
val |= m_bits.test(i) * (1u << i);
return val;
Expand Down
2 changes: 1 addition & 1 deletion GeneralsMD/Code/GameEngine/Include/Common/BitFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class BitFlags
UnsignedInt toUnsignedInt() const noexcept
{
UnsignedInt val = 0;
const UnsignedInt count = min(m_bits.size(), sizeof(val) * 8);
const UnsignedInt count = (m_bits.size() < sizeof(val) * 8) ? m_bits.size() : sizeof(val) * 8;
for (UnsignedInt i = 0; i < count; ++i)
val |= m_bits.test(i) * (1u << i);
return val;
Expand Down
Loading