Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wjr-z committed Aug 15, 2024
1 parent f8f7165 commit f2cbda0
Show file tree
Hide file tree
Showing 27 changed files with 4,424 additions and 88 deletions.
4 changes: 2 additions & 2 deletions include/wjr/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ inline void __assert_handler(const char *expr, const char *file, const char *fun
::wjr::__assert_handler(#expr, WJR_FILE, WJR_CURRENT_FUNCTION, WJR_LINE, \
##__VA_ARGS__); \
} \
} while (0)
} while (false)

// do nothing
#define WJR_ASSERT_UNCHECK_I(expr, ...) \
do { \
} while (0)
} while (false)

// level = [0, 2]
// The higher the level, the less likely it is to be detected
Expand Down
12 changes: 6 additions & 6 deletions include/wjr/biginteger/biginteger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ from_chars_result<const char *> __from_chars_impl(const char *first, const char
dssize = __fasts_conditional_negate<int32_t>(sign, dssize);
dst->set_ssize(dssize);
return {first, std::errc{}};
} while (0);
} while (false);

dst->clear();
return {__first, std::errc::invalid_argument};
Expand Down Expand Up @@ -2065,7 +2065,7 @@ void __addsubmul_impl(basic_biginteger<S> *dst, const biginteger_data *lhs, uint
}

new_dusize = normalize(dp, new_dusize);
} while (0);
} while (false);
}

dst->set_ssize(__fasts_conditional_negate<int32_t>(dssize < 0, new_dusize));
Expand Down Expand Up @@ -3040,7 +3040,7 @@ void __cfdiv_r_2exp_impl(basic_biginteger<S> *rem, const biginteger_data *num,

rem->set_ssize(0);
return;
} while (0);
} while (false);

rem->reserve(offset + 1);
rp = rem->data();
Expand Down Expand Up @@ -3082,7 +3082,7 @@ void __urandom_bit_impl(basic_biginteger<S> *dst, uint32_t size,
for (uint64_t i = 0; i < dusize; ++i) {
dp[i] = engine();
}
} while (0);
} while (false);

if (size != 0) {
dp[dusize] = engine() >> (64 - size);
Expand Down Expand Up @@ -3112,7 +3112,7 @@ void __urandom_exact_bit_impl(basic_biginteger<S> *dst, uint32_t size,
for (uint64_t i = 0; i < dusize; ++i) {
dp[i] = engine();
}
} while (0);
} while (false);

do {
uint64_t high = (uint64_t)(1) << size;
Expand All @@ -3122,7 +3122,7 @@ void __urandom_exact_bit_impl(basic_biginteger<S> *dst, uint32_t size,
}

dp[dusize] = high;
} while (0);
} while (false);

dst->set_ssize(dssize);
}
Expand Down
16 changes: 8 additions & 8 deletions include/wjr/container/generic/bplus_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ class basic_bplus_tree {
}

leaf = static_cast<leaf_node_type *>(node);
} while (0);
} while (false);

unsigned int pos = iter.get_pos();
unsigned int cur_size = -leaf->m_size;
Expand Down Expand Up @@ -1047,7 +1047,7 @@ class basic_bplus_tree {
NOT_LEFTMOST_AT_INNER:
pos = __search<Upper, floor_half, node_size, 1>(current->as_inner(), cur_size,
key, comp);
} while (0);
} while (false);

current = current->as_inner()->m_sons[pos];
cur_size = current->m_size;
Expand Down Expand Up @@ -1123,7 +1123,7 @@ class basic_bplus_tree {
return B; \
} \
} \
} while (0)
} while (false)
#define WJR_REGISTER_BLPUS_SEARCH_4(A, B, C, D, E) \
do { \
if constexpr (E > Max) { \
Expand Down Expand Up @@ -1158,7 +1158,7 @@ class basic_bplus_tree {
return D; \
} \
} \
} while (0)
} while (false)

WJR_REGISTER_BLPUS_SEARCH_2(1, 2, 3);
WJR_REGISTER_BLPUS_SEARCH_2(3, 4, 5);
Expand Down Expand Up @@ -1242,7 +1242,7 @@ class basic_bplus_tree {
return tmp->m_size;
}
}
} while (0);
} while (false);

do {
if (pos != 0) {
Expand All @@ -1263,7 +1263,7 @@ class basic_bplus_tree {
}

lhs = nullptr;
} while (0);
} while (false);

return size;
}
Expand Down Expand Up @@ -1438,7 +1438,7 @@ class basic_bplus_tree {
}

return;
} while (0);
} while (false);

lhs->m_size = merge_size;
_Alty_traits::deallocate(__get_allocator(), (uint8_t *)rhs,
Expand Down Expand Up @@ -1617,7 +1617,7 @@ class basic_bplus_tree {
current->as_inner()->m_keys[tmp_pos - 1] = rhs->__get_key(0);

return iterator(leaf, pos);
} while (0);
} while (false);

lhs->m_size = -(merge_size - 1);
remove_uninit(rhs);
Expand Down
8 changes: 4 additions & 4 deletions include/wjr/crtp/class_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ struct control_copy_ctor_base : Mybase {
using Mybase ::Mybase;
control_copy_ctor_base() = default;
constexpr control_copy_ctor_base(const control_copy_ctor_base &other) noexcept(
noexcept(Mybase::__copy_construct(static_cast<const Mybase &>(other))))
noexcept(std::declval<Mybase>().__copy_construct(std::declval<const Mybase &>())))
: Mybase(enable_default_constructor) {
Mybase::__copy_construct(static_cast<const Mybase &>(other));
}
Expand All @@ -258,7 +258,7 @@ struct control_move_ctor_base : Mybase {
control_move_ctor_base() = default;
control_move_ctor_base(const control_move_ctor_base &) = default;
constexpr control_move_ctor_base(control_move_ctor_base &&other) noexcept(
noexcept(Mybase::__move_construct(static_cast<Mybase &&>(other))))
noexcept(std::declval<Mybase>().__move_construct(std::declval<Mybase &&>())))
: Mybase(enable_default_constructor) {
Mybase::__move_construct(static_cast<Mybase &&>(other));
}
Expand All @@ -278,7 +278,7 @@ struct control_copy_assign_base : Mybase {
control_copy_assign_base(control_copy_assign_base &&) = default;
constexpr control_copy_assign_base &
operator=(const control_copy_assign_base &other) noexcept(
noexcept(Mybase::__copy_assign(static_cast<const Mybase &>(other)))) {
noexcept(std::declval<Mybase>().__copy_assign(std::declval<const Mybase &>()))) {
Mybase::__copy_assign(static_cast<const Mybase &>(other));
return *this;
}
Expand All @@ -298,7 +298,7 @@ struct control_move_assign_base : Mybase {
control_move_assign_base &operator=(const control_move_assign_base &) = default;
constexpr control_move_assign_base &
operator=(control_move_assign_base &&other) noexcept(
noexcept(Mybase::__move_assign(static_cast<Mybase &&>(other)))) {
noexcept(std::declval<Mybase>().__move_assign(std::declval<Mybase &&>()))) {
Mybase::__move_assign(static_cast<Mybase &&>(other));
return *this;
}
Expand Down
4 changes: 2 additions & 2 deletions include/wjr/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ using compressed_expected = expected<T, compressed_unexpected<E, init>>;
if (auto exp = (__VA_ARGS__); WJR_UNLIKELY(!exp)) { \
return ::wjr::unexpected(std::move(exp).error()); \
} \
} while (0)
} while (false)

#define WJR_EXPECTED_INIT(NAME, ...) \
auto NAME = (__VA_ARGS__); \
Expand All @@ -1775,7 +1775,7 @@ using compressed_expected = expected<T, compressed_unexpected<E, init>>;
} else { \
VAR = *std::move(exp); \
} \
} while (0)
} while (false)

} // namespace wjr

Expand Down
5 changes: 2 additions & 3 deletions include/wjr/format/charconv-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ class char_converter_t {
template <uint64_t Base = 0>
WJR_CONST static constexpr uint8_t to(uint8_t x) noexcept {
if constexpr (Base == 0) {
WJR_ASSERT_L3(x < 36);
WJR_ASSERT_ASSUME_L3(x < 36);
} else {
WJR_ASSERT_L3(x < Base);
WJR_ASSERT_ASSUME_L3(x < Base);
}

if constexpr (Base == 0 || Base > 10) {

if (WJR_BUILTIN_CONSTANT_P_TRUE(x < 10)) {
return x + '0';
}
Expand Down
Loading

0 comments on commit f2cbda0

Please sign in to comment.