Skip to content

Commit 154cd9c

Browse files
committed
Fix constexpr insert for Clang 3.7
The iterator-based insert(const_iterator, size_type, value_type) function relies on traits_type::move() to shift the existing null terminator to its new position. Clang 3.7's constexpr evaluator does not handle this correctly, causing the following test to fail: static_string<3>{"ab"}.insert(2, 1, 'c') == "abc" Add an explicit term() call, guarded by a preprocessor conditional for Clang 3.7, to ensure proper null termination.
1 parent aa3f7ea commit 154cd9c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

include/boost/static_string/static_string.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6707,6 +6707,9 @@ insert(
67076707
traits_type::move(&curr_data[index + count], &curr_data[index], curr_size - index + 1);
67086708
traits_type::assign(&curr_data[index], count, ch);
67096709
this->size_impl(curr_size + count);
6710+
#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ == 7
6711+
term();
6712+
#endif
67106713
return &curr_data[index];
67116714
}
67126715

0 commit comments

Comments
 (0)