Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit aff4ddb

Browse files
committed
radix_tree: fix assing_val
Realocating path should be taken for values which are instances of basic_inline_string<CharT, Traits> (not only for CharT = char).
1 parent 26da8fa commit aff4ddb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

include/libpmemobj++/detail/template_helpers.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ using is_transparent = typename Compare::is_transparent;
4747
template <typename Compare>
4848
using has_is_transparent = detail::supports<Compare, is_transparent>;
4949

50+
/* Check if type is pmem::obj::basic_inline_string */
51+
template <typename>
52+
struct is_inline_string : std::false_type {
53+
};
54+
55+
template <typename CharT, typename Traits>
56+
struct is_inline_string<obj::experimental::basic_inline_string<CharT, Traits>>
57+
: std::true_type {
58+
};
59+
5060
/* Check if type is pmem::obj::basic_string or
5161
* pmem::obj::basic_inline_string */
5262
template <typename>

include/libpmemobj++/experimental/radix_tree.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,14 @@ struct radix_tree<Key, Value, BytesView>::radix_tree_iterator {
598598

599599
template <typename V = Value,
600600
typename Enable = typename std::enable_if<
601-
std::is_same<V, inline_string>::value>::type>
602-
void assign_val(string_view rhs);
601+
detail::is_inline_string<V>::value>::type>
602+
void assign_val(basic_string_view<typename V::value_type,
603+
typename V::traits_type>
604+
rhs);
603605

604606
template <typename T, typename V = Value,
605607
typename Enable = typename std::enable_if<
606-
!std::is_same<V, inline_string>::value>::type>
608+
!detail::is_inline_string<V>::value>::type>
607609
void assign_val(T &&rhs);
608610

609611
radix_tree_iterator &operator++();
@@ -2777,7 +2779,7 @@ template <bool IsConst>
27772779
template <typename V, typename Enable>
27782780
void
27792781
radix_tree<Key, Value, BytesView>::radix_tree_iterator<IsConst>::assign_val(
2780-
string_view rhs)
2782+
basic_string_view<typename V::value_type, typename V::traits_type> rhs)
27812783
{
27822784
auto pop = pool_base(pmemobj_pool_by_ptr(leaf_));
27832785

0 commit comments

Comments
 (0)