Skip to content

Commit

Permalink
[coding-opt] 使用 kerbal 中的组件替换 std 中的组件
Browse files Browse the repository at this point in the history
  • Loading branch information
WentsingNee committed Jun 10, 2024
1 parent 9f9c7cc commit dc00753
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/kerbal/container/detail/avl_base/avl_base.decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

#if __cplusplus >= 201703L
# if __has_include(<memory_resource>)
# include <kerbal/type_traits/is_trivially_destructible.hpp>
# include <memory_resource>
# endif
#endif
Expand Down Expand Up @@ -1079,7 +1080,7 @@ namespace kerbal
static void k_destroy_node_and_offsprings(std::pmr::polymorphic_allocator<Node> & alloc, node_base * start)
KERBAL_CONDITIONAL_NOEXCEPT(
(
!std::is_trivially_destructible<Entity>::value ?
!kerbal::type_traits::try_test_is_trivially_destructible<Entity>::IS_TRUE::value ?
noexcept(k_destroy_node_and_offsprings_impl(alloc, start, DES_OFF_VER_DESTROY_BUT_NO_DEALLOCATE())) :
true
) &&
Expand Down
11 changes: 9 additions & 2 deletions include/kerbal/container/detail/avl_base/avl_base.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
# include <initializer_list>
#endif

#if __cplusplus >= 201703L
# if __has_include(<memory_resource>)
# include <kerbal/type_traits/is_trivially_destructible.hpp>
# include <memory_resource>
# endif
#endif

#include <cstddef>


Expand Down Expand Up @@ -2831,15 +2838,15 @@ namespace kerbal
void avl_type_only<Entity>::k_destroy_node_and_offsprings(std::pmr::polymorphic_allocator<Node> & alloc, node_base * start)
KERBAL_CONDITIONAL_NOEXCEPT(
(
!std::is_trivially_destructible<Entity>::value ?
!kerbal::type_traits::try_test_is_trivially_destructible<Entity>::IS_TRUE::value ?
noexcept(k_destroy_node_and_offsprings_impl(alloc, start, DES_OFF_VER_DESTROY_BUT_NO_DEALLOCATE())) :
true
) &&
noexcept(k_destroy_node_and_offsprings_impl(alloc, start, DES_OFF_VER_DEFAULT()))
)
{
if (typeid(*alloc.resource()) == typeid(std::pmr::monotonic_buffer_resource)) {
if constexpr (!std::is_trivially_destructible<Entity>::value) {
if constexpr (!kerbal::type_traits::try_test_is_trivially_destructible<Entity>::IS_TRUE::value) {
k_destroy_node_and_offsprings_impl(alloc, start, DES_OFF_VER_DESTROY_BUT_NO_DEALLOCATE());
}
} else {
Expand Down

0 comments on commit dc00753

Please sign in to comment.