Skip to content

Commit d169041

Browse files
authored
Merge pull request #465 from ckormanyos/more_syntax
Handle some more sonar syntax
2 parents abc99c1 + ee35e6d commit d169041

File tree

6 files changed

+78
-70
lines changed

6 files changed

+78
-70
lines changed

boost/multiprecision/uintwide_t_backend.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2019 - 2024. //
2+
// Copyright Christopher Kormanyos 2019 - 2025. //
33
// Distributed under the Boost Software License, //
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt //
55
// or copy at http://www.boost.org/LICENSE_1_0.txt) //
@@ -785,7 +785,7 @@
785785
(
786786
UnsignedIntegralType* result,
787787
const uintwide_t_backend<MyWidth2, MyLimbType, MyAllocatorType>& val,
788-
std::enable_if_t<( (std::is_integral<UnsignedIntegralType>::value)
788+
std::enable_if_t<( std::is_integral<UnsignedIntegralType>::value
789789
&& (!std::is_signed <UnsignedIntegralType>::value))>* p_nullparam = nullptr
790790
) -> void
791791
{

examples/example001_mul_div.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2018 - 2024. //
2+
// Copyright Christopher Kormanyos 2018 - 2025. //
33
// Distributed under the Boost Software License, //
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt //
55
// or copy at http://www.boost.org/LICENSE_1_0.txt) //
@@ -8,14 +8,6 @@
88
#include <examples/example_uintwide_t.h>
99
#include <math/wide_integer/uintwide_t.h>
1010

11-
#if (defined(__GNUC__) && defined(__AVR__) && (__GNUC__ < 10))
12-
#define WIDE_INTEGER_EXAMPLE001_CONSTEXPR_OR_CONST const // NOLINT(cppcoreguidelines-macro-usage)
13-
#define WIDE_INTEGER_EXAMPLE001_CONSTEXPR_IS_COMPILE_TIME_CONSTANT 0 // NOLINT(cppcoreguidelines-macro-usage)
14-
#else
15-
#define WIDE_INTEGER_EXAMPLE001_CONSTEXPR_OR_CONST constexpr // NOLINT(cppcoreguidelines-macro-usage)
16-
#define WIDE_INTEGER_EXAMPLE001_CONSTEXPR_IS_COMPILE_TIME_CONSTANT 1 // NOLINT(cppcoreguidelines-macro-usage)
17-
#endif
18-
1911
#if defined(WIDE_INTEGER_NAMESPACE)
2012
auto WIDE_INTEGER_NAMESPACE::math::wide_integer::example001_mul_div() -> bool
2113
#else
@@ -34,22 +26,19 @@ auto ::math::wide_integer::example001_mul_div() -> bool
3426
&& std::numeric_limits<uint512_t>::digits == static_cast<int>(INT16_C(512))),
3527
"Error: Incorrect digit count for this example");
3628

37-
WIDE_INTEGER_EXAMPLE001_CONSTEXPR_OR_CONST uint256_t a("0xF4DF741DE58BCB2F37F18372026EF9CBCFC456CB80AF54D53BDEED78410065DE");
38-
WIDE_INTEGER_EXAMPLE001_CONSTEXPR_OR_CONST uint256_t b("0x166D63E0202B3D90ECCEAA046341AB504658F55B974A7FD63733ECF89DD0DF75");
29+
constexpr uint256_t a("0xF4DF741DE58BCB2F37F18372026EF9CBCFC456CB80AF54D53BDEED78410065DE");
30+
constexpr uint256_t b("0x166D63E0202B3D90ECCEAA046341AB504658F55B974A7FD63733ECF89DD0DF75");
3931

40-
WIDE_INTEGER_EXAMPLE001_CONSTEXPR_OR_CONST auto c = uint512_t(a) * uint512_t(b);
41-
WIDE_INTEGER_EXAMPLE001_CONSTEXPR_OR_CONST auto d = (a / b);
32+
constexpr auto c = uint512_t(a) * uint512_t(b);
33+
constexpr auto d = (a / b);
4234

43-
WIDE_INTEGER_EXAMPLE001_CONSTEXPR_OR_CONST auto result_is_ok =
35+
constexpr auto result_is_ok =
4436
(
4537
(c == "0x1573D6A7CEA734D99865C4F428184983CDB018B80E9CC44B83C773FBE11993E7E491A360C57EB4306C61F9A04F7F7D99BE3676AAD2D71C5592D5AE70F84AF076")
4638
&& (static_cast<std::uint_fast8_t>(d) == static_cast<std::uint_fast8_t>(UINT8_C(10)))
4739
);
4840

49-
#if (defined(WIDE_INTEGER_EXAMPLE001_CONSTEXPR_IS_COMPILE_TIME_CONSTANT) \
50-
&& (WIDE_INTEGER_EXAMPLE001_CONSTEXPR_IS_COMPILE_TIME_CONSTANT == 1))
5141
static_assert(result_is_ok, "Error: example001_mul_div not OK!");
52-
#endif
5342

5443
return result_is_ok;
5544
}

math/wide_integer/cpp.hint

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11

2-
#define __cplusplus 199711L
2+
#define __cplusplus 201703L
3+
4+
#define WIDE_INTEGER_NUM_LIMITS_CLASS_TYPE class
35

46
#define WIDE_INTEGER_NAMESPACE ckormanyos
57

68
#if defined(WIDE_INTEGER_NAMESPACE)
7-
#define WIDE_INTEGER_NAMESPACE_BEGIN namespace WIDE_INTEGER_NAMESPACE { // NOLINT(cppcoreguidelines-macro-usage)
8-
#define WIDE_INTEGER_NAMESPACE_END } // namespace WIDE_INTEGER_NAMESPACE // NOLINT(cppcoreguidelines-macro-usage)
9+
#define WIDE_INTEGER_NAMESPACE_BEGIN namespace WIDE_INTEGER_NAMESPACE {
10+
#define WIDE_INTEGER_NAMESPACE_END }
911
#else
1012
#define WIDE_INTEGER_NAMESPACE_BEGIN
1113
#define WIDE_INTEGER_NAMESPACE_END

math/wide_integer/uintwide_t.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,8 @@
580580
WIDE_INTEGER_NODISCARD constexpr auto front() -> reference { return elems[static_cast<size_type>(UINT8_C(0))]; }
581581
WIDE_INTEGER_NODISCARD constexpr auto front() const -> const_reference { return elems[static_cast<size_type>(UINT8_C(0))]; }
582582

583-
WIDE_INTEGER_NODISCARD constexpr auto back() -> reference { return elems[static_cast<size_type>(N - static_cast<size_type>(UINT8_C(1)))]; }
584-
WIDE_INTEGER_NODISCARD constexpr auto back() const -> const_reference { return elems[static_cast<size_type>(N - static_cast<size_type>(UINT8_C(1)))]; }
583+
WIDE_INTEGER_NODISCARD constexpr auto back() -> reference { return elems[N - UINT8_C(1)]; }
584+
WIDE_INTEGER_NODISCARD constexpr auto back() const -> const_reference { return elems[N - UINT8_C(1)]; }
585585

586586
WIDE_INTEGER_NODISCARD static constexpr auto size() -> size_type { return N; }
587587
WIDE_INTEGER_NODISCARD static constexpr auto empty() -> bool { return false; }
@@ -2937,9 +2937,9 @@
29372937

29382938
if(field_width != static_cast<unsigned_fast_type>(UINT8_C(0)))
29392939
{
2940-
field_width = (detail::min_unsafe)(field_width, static_cast<unsigned_fast_type>(str_temp.size() - static_cast<size_t>(UINT8_C(1)))); // LCOV_EXCL_LINE
2940+
field_width = (detail::min_unsafe)(field_width, static_cast<unsigned_fast_type>(str_temp.size() - UINT8_C(1))); // LCOV_EXCL_LINE
29412941

2942-
while(static_cast<signed_fast_type>(pos) > static_cast<signed_fast_type>((str_temp.size() - static_cast<size_t>(UINT8_C(1))) - field_width)) // NOLINT(altera-id-dependent-backward-branch)
2942+
while(static_cast<signed_fast_type>(pos) > static_cast<signed_fast_type>((str_temp.size() - UINT8_C(1)) - static_cast<size_t>(field_width))) // NOLINT(altera-id-dependent-backward-branch)
29432943
{
29442944
str_temp[static_cast<typename string_storage_oct_type::size_type>(--pos)] = fill_char_str;
29452945
}
@@ -3023,15 +3023,15 @@
30233023

30243024
if(field_width != static_cast<unsigned_fast_type>(UINT8_C(0)))
30253025
{
3026-
field_width = (detail::min_unsafe)(field_width, static_cast<unsigned_fast_type>(str_temp.size() - static_cast<size_t>(UINT8_C(1)))); // LCOV_EXCL_LINE
3026+
field_width = (detail::min_unsafe)(field_width, static_cast<unsigned_fast_type>(str_temp.size() - size_t { UINT8_C(1) })); // LCOV_EXCL_LINE
30273027

3028-
while(static_cast<signed_fast_type>(pos) > static_cast<signed_fast_type>((str_temp.size() - static_cast<size_t>(UINT8_C(1))) - field_width)) // NOLINT(altera-id-dependent-backward-branch)
3028+
while(static_cast<signed_fast_type>(pos) > static_cast<signed_fast_type>((str_temp.size() - size_t { UINT8_C(1) }) - static_cast<size_t>(field_width))) // NOLINT(altera-id-dependent-backward-branch)
30293029
{
30303030
str_temp[static_cast<typename string_storage_dec_type::size_type>(--pos)] = fill_char_str;
30313031
}
30323032
}
30333033

3034-
str_temp[static_cast<typename string_storage_dec_type::size_type>(str_temp.size() - static_cast<size_t>(UINT8_C(1)))] = '\0';
3034+
str_temp[static_cast<typename string_storage_dec_type::size_type>(str_temp.size() - size_t { UINT8_C(1) })] = '\0';
30353035

30363036
detail::strcpy_unsafe(str_result, str_temp.data() + pos);
30373037
}
@@ -3060,7 +3060,7 @@
30603060
{
30613061
static_cast<signed_fast_type>
30623062
(
3063-
string_storage_hex_type::static_size() - static_cast<size_t>(UINT8_C(1)) // LCOV_EXCL_LINE
3063+
string_storage_hex_type::static_size() - size_t { UINT8_C(1) } // LCOV_EXCL_LINE
30643064
)
30653065
};
30663066

@@ -3095,9 +3095,9 @@
30953095

30963096
if(field_width != static_cast<unsigned_fast_type>(UINT8_C(0)))
30973097
{
3098-
field_width = (detail::min_unsafe)(field_width, static_cast<unsigned_fast_type>(str_temp.size() - static_cast<size_t>(UINT8_C(1)))); // LCOV_EXCL_LINE
3098+
field_width = (detail::min_unsafe)(field_width, static_cast<unsigned_fast_type>(str_temp.size() - size_t { UINT8_C(1) })); // LCOV_EXCL_LINE
30993099

3100-
while(static_cast<signed_fast_type>(pos) > static_cast<signed_fast_type>((str_temp.size() - static_cast<size_t>(UINT8_C(1))) - field_width)) // NOLINT(altera-id-dependent-backward-branch)
3100+
while(static_cast<signed_fast_type>(pos) > static_cast<signed_fast_type>((str_temp.size() - size_t { UINT8_C(1) }) - static_cast<size_t>(field_width))) // NOLINT(altera-id-dependent-backward-branch)
31013101
{
31023102
str_temp[static_cast<typename string_storage_hex_type::size_type>(--pos)] = fill_char_str;
31033103
}
@@ -4826,9 +4826,9 @@
48264826

48274827
using uu_array_type =
48284828
std::conditional_t<std::is_same<AllocatorType, void>::value,
4829-
detail::fixed_static_array <limb_type, static_cast<size_t>(number_of_limbs + static_cast<size_t>(UINT8_C(1)))>,
4829+
detail::fixed_static_array <limb_type, number_of_limbs + size_t { UINT8_C(1) }>,
48304830
detail::fixed_dynamic_array<limb_type,
4831-
static_cast<size_t>(number_of_limbs + static_cast<size_t>(UINT8_C(1))),
4831+
number_of_limbs + size_t { UINT8_C(1) },
48324832
typename std::allocator_traits<std::conditional_t<std::is_same<AllocatorType, void>::value,
48334833
std::allocator<void>,
48344834
AllocatorType>>::template rebind_alloc<limb_type>>>;
@@ -6195,9 +6195,9 @@
61956195
const auto left_shift_amount =
61966196
static_cast<unsigned_fast_type>
61976197
(
6198-
(msb_pos_mod_3 == static_cast<unsigned_fast_type>(UINT8_C(0)))
6199-
? static_cast<unsigned_fast_type>(UINT8_C(1)) + static_cast<unsigned_fast_type>(static_cast<unsigned_fast_type>(msb_pos + static_cast<unsigned_fast_type>(UINT8_C(0))) / 3U)
6200-
: static_cast<unsigned_fast_type>(UINT8_C(1)) + static_cast<unsigned_fast_type>(static_cast<unsigned_fast_type>(msb_pos + static_cast<unsigned_fast_type>(static_cast<unsigned_fast_type>(UINT8_C(3)) - msb_pos_mod_3)) / 3U)
6198+
(msb_pos_mod_3 == unsigned_fast_type { UINT8_C(0) })
6199+
? unsigned_fast_type { UINT8_C(1) } + static_cast<unsigned_fast_type>(msb_pos / unsigned_fast_type { UINT8_C(3) })
6200+
: unsigned_fast_type { UINT8_C(1) } + static_cast<unsigned_fast_type>((msb_pos + (unsigned_fast_type { UINT8_C(3) } - msb_pos_mod_3)) / unsigned_fast_type { UINT8_C(3) })
62016201
);
62026202

62036203
auto u = static_cast<local_wide_integer_type>(static_cast<unsigned>(UINT8_C(1))) << left_shift_amount;
@@ -6280,9 +6280,9 @@
62806280
const auto left_shift_amount =
62816281
static_cast<unsigned_fast_type>
62826282
(
6283-
((msb_pos_mod_k == static_cast<unsigned_fast_type>(UINT8_C(0)))
6284-
? static_cast<unsigned_fast_type>(UINT8_C(1)) + static_cast<unsigned_fast_type>(static_cast<unsigned_fast_type>(msb_pos + static_cast<unsigned_fast_type>(UINT8_C(0))) / k)
6285-
: static_cast<unsigned_fast_type>(UINT8_C(1)) + static_cast<unsigned_fast_type>(static_cast<unsigned_fast_type>(msb_pos + static_cast<unsigned_fast_type>(k - msb_pos_mod_k)) / k))
6283+
(msb_pos_mod_k == unsigned_fast_type { UINT8_C(0) })
6284+
? unsigned_fast_type { UINT8_C(1) } + static_cast<unsigned_fast_type>(msb_pos / unsigned_fast_type { k })
6285+
: unsigned_fast_type { UINT8_C(1) } + static_cast<unsigned_fast_type>((msb_pos + (unsigned_fast_type { k } - msb_pos_mod_k)) / unsigned_fast_type { k })
62866286
);
62876287

62886288
auto u = static_cast<local_wide_integer_type>(static_cast<unsigned>(UINT8_C(1))) << left_shift_amount;
@@ -6783,9 +6783,9 @@
67836783
explicit constexpr uniform_int_distribution(const param_type& other_params)
67846784
: my_params(other_params) { }
67856785

6786-
constexpr uniform_int_distribution(const uniform_int_distribution& other_distribution) = delete;
6786+
constexpr uniform_int_distribution(const uniform_int_distribution& other) : my_params(other.my_params) { }
67876787

6788-
constexpr uniform_int_distribution(uniform_int_distribution&& other) noexcept : my_params(other.my_params) { }
6788+
constexpr uniform_int_distribution(uniform_int_distribution&& other) noexcept : my_params(static_cast<param_type&&>(other.my_params)) { }
67896789

67906790
~uniform_int_distribution() = default;
67916791

@@ -6801,7 +6801,7 @@
68016801

68026802
auto constexpr operator=(uniform_int_distribution&& other) noexcept -> uniform_int_distribution&
68036803
{
6804-
my_params = other.my_params;
6804+
my_params = static_cast<param_type&&>(other.my_params);
68056805

68066806
return *this;
68076807
}

0 commit comments

Comments
 (0)