Skip to content

Commit 023a2f5

Browse files
konardclaude
andcommitted
Fix Codacy warning: replace <climits>/CHAR_BIT with std::numeric_limits
Remove `#include <climits>` which Cppcheck flagged as "Include file not found" in Codacy Static Code Analysis. Replace `CHAR_BIT` with `std::numeric_limits<unsigned char>::digits` from `<limits>` (already included), which is semantically equivalent and avoids the missing-include warning. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d29a182 commit 023a2f5

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

  • cpp/Platform.Numbers

cpp/Platform.Numbers/Bit.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22
#include <cstdint>
3-
#include <climits>
43
#include <limits>
54

65
namespace Platform::Numbers::Bit
@@ -60,11 +59,11 @@ namespace Platform::Numbers::Bit
6059
{
6160
if (shift < 0)
6261
{
63-
shift = sizeof(T) * CHAR_BIT + shift;
62+
shift = sizeof(T) * std::numeric_limits<unsigned char>::digits + shift;
6463
}
6564
if (limit < 0)
6665
{
67-
limit = sizeof(T) * CHAR_BIT + limit;
66+
limit = sizeof(T) * std::numeric_limits<unsigned char>::digits + limit;
6867
}
6968
auto sourceMask = ~(std::numeric_limits<T>::max() << limit) & std::numeric_limits<T>::max();
7069
auto targetMask = ~(sourceMask << shift);
@@ -76,11 +75,11 @@ namespace Platform::Numbers::Bit
7675
{
7776
if (shift < 0)
7877
{
79-
shift = sizeof(T) * CHAR_BIT + shift;
78+
shift = sizeof(T) * std::numeric_limits<unsigned char>::digits + shift;
8079
}
8180
if (limit < 0)
8281
{
83-
limit = sizeof(T) * CHAR_BIT + limit;
82+
limit = sizeof(T) * std::numeric_limits<unsigned char>::digits + limit;
8483
}
8584
auto sourceMask = ~(std::numeric_limits<T>::max() << limit) & std::numeric_limits<T>::max();
8685
auto targetMask = sourceMask << shift;

0 commit comments

Comments
 (0)