Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
wjr-z committed Jul 14, 2024
1 parent 76d1684 commit f29c1bd
Show file tree
Hide file tree
Showing 12 changed files with 475 additions and 209 deletions.
4 changes: 0 additions & 4 deletions include/wjr/biginteger/biginteger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,10 +1109,6 @@ class basic_biginteger {
}

basic_biginteger &operator=(const basic_biginteger &other) {
if (WJR_UNLIKELY(this == std::addressof(other))) {
return *this;
}

m_vec = other.m_vec;
set_ssize(other.get_ssize());
return *this;
Expand Down
2 changes: 2 additions & 0 deletions include/wjr/compressed_pair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class WJR_EMPTY_BASES compressed_pair final : __compressed_pair_base1<T, U>,
: Mybase1(std::forward<Other1>(_First)), Mybase2(std::forward<Other2>(_Second)) {}
#endif

private:
template <typename Tuple1, typename Tuple2, size_t... N1, size_t... N2>
constexpr compressed_pair(
Tuple1 &tp1, Tuple2 &tp2, std::index_sequence<N1...>,
Expand All @@ -199,6 +200,7 @@ class WJR_EMPTY_BASES compressed_pair final : __compressed_pair_base1<T, U>,
: Mybase1(std::get<N1>(std::move(tp1))...),
Mybase2(std::get<N2>(std::move(tp2))...) {}

public:
template <typename... Args1, typename... Args2>
constexpr compressed_pair(
std::piecewise_construct_t, tuple<Args1...> tp1,
Expand Down
9 changes: 3 additions & 6 deletions include/wjr/container/generic/bplus_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ class bplus_tree_const_iterator {
bplus_tree_const_iterator() = default;
bplus_tree_const_iterator(const bplus_tree_const_iterator &) = default;
bplus_tree_const_iterator(bplus_tree_const_iterator &&) = default;
bplus_tree_const_iterator &
operator=(const bplus_tree_const_iterator &) = default;
bplus_tree_const_iterator &operator=(const bplus_tree_const_iterator &) = default;
bplus_tree_const_iterator &operator=(bplus_tree_const_iterator &&) = default;
~bplus_tree_const_iterator() = default;

Expand Down Expand Up @@ -561,10 +560,8 @@ class basic_bplus_tree {

basic_bplus_tree &operator=(basic_bplus_tree &&other) noexcept(
noexcept(storage_fn_type::move_assign(*this, std::move(other)))) {
if (WJR_LIKELY(this != std::addressof(other))) {
storage_fn_type::move_assign(*this, std::move(other));
}

WJR_ASSERT(this != std::addressof(other));
storage_fn_type::move_assign(*this, std::move(other));
return *this;
}

Expand Down
18 changes: 12 additions & 6 deletions include/wjr/container/generic/details.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ template <typename CharT, typename Traits, typename Alloc>
WJR_INTRINSIC_INLINE void
__uninitialized_resize(std::basic_string<CharT, Traits, Alloc> &str,
typename std::basic_string<CharT, Traits, Alloc>::size_type sz) {
using Size = typename std::basic_string<CharT, Traits, Alloc>::size_type;
str.resize_and_overwrite(sz, [](char *, Size sz) { return sz; });
}

#define __WJR_REGISTER_STRING_UNINITIALIZED_RESIZE_TEMPLATE(Name, Container)
#define __WJR_REGISTER_STRING_UNINITIALIZED_RESIZE_CLASS(...)
#define __WJR_REGISTER_STRING_UNINITIALIZED_RESIZE_TEMPLATE(...)
#define __WJR_REGISTER_STRING_UNINITIALIZED_RESIZE_HACKER(...)

#elif (defined(__clang_major__) && __clang_major__ <= 11) || \
(defined(_MSC_VER) && _MSC_VER <= 1920)
Expand Down Expand Up @@ -115,6 +118,13 @@ void string_set_length_hacker(Container &bank, typename Container::size_type sz)
}
#endif

#define __WJR_REGISTER_STRING_UNINITIALIZED_RESIZE_HACKER(Name, Container) \
template <> \
inline void string_set_length_hacker<Container>(Container & bank, \
typename Container::size_type sz) { \
WJR_PP_CONCAT(string_set_length_hacker_of_, Name)(bank, sz); \
};

#if defined(__GLIBCXX__)
#define __WJR_REGISTER_STRING_UNINITIALIZED_RESIZE_TEMPLATE(Name, Container) \
template struct WJR_PP_CONCAT( \
Expand Down Expand Up @@ -167,11 +177,7 @@ struct __uninitialized_append_fn_impl : append_fn_impl_base<Container> {
#define WJR_REGISTER_STRING_UNINITIALIZED_RESIZE(Name, Container) \
__WJR_REGISTER_STRING_UNINITIALIZED_RESIZE_CLASS(Name, Container); \
__WJR_REGISTER_STRING_UNINITIALIZED_RESIZE_TEMPLATE(Name, Container); \
template <> \
inline void string_set_length_hacker<Container>(Container & bank, \
typename Container::size_type sz) { \
WJR_PP_CONCAT(string_set_length_hacker_of_, Name)(bank, sz); \
}; \
__WJR_REGISTER_STRING_UNINITIALIZED_RESIZE_HACKER(Name, Container); \
template <> \
struct resize_fn_impl<Container> : __uninitialized_resize_fn_impl<Container> {}; \
template <> \
Expand Down
6 changes: 2 additions & 4 deletions include/wjr/container/generic/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,8 @@ class basic_vector {

WJR_CONSTEXPR20 basic_vector &operator=(basic_vector &&other) noexcept(
noexcept(storage_fn_type::move_assign(*this, std::move(other)))) {
if (WJR_LIKELY(this != std::addressof(other))) {
storage_fn_type::move_assign(*this, std::move(other));
}

WJR_ASSERT(this != std::addressof(other));
storage_fn_type::move_assign(*this, std::move(other));
return *this;
}

Expand Down
Loading

0 comments on commit f29c1bd

Please sign in to comment.