mirror of
https://github.com/boostorg/static_string.git
synced 2026-01-19 04:42:12 +00:00
Work around a Clang 3.7 bug affecting constexpr insert()
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.
This commit is contained in:
@@ -6707,6 +6707,9 @@ insert(
|
||||
traits_type::move(&curr_data[index + count], &curr_data[index], curr_size - index + 1);
|
||||
traits_type::assign(&curr_data[index], count, ch);
|
||||
this->size_impl(curr_size + count);
|
||||
#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ == 7
|
||||
term();
|
||||
#endif
|
||||
return &curr_data[index];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user