mirror of
https://github.com/boostorg/static_string.git
synced 2026-01-19 04:42:12 +00:00
Replace the implementation of cxper_char_traits::move() with a simpler one
Reason: See the new code comment.
This commit is contained in:
committed by
Gennaro Prota
parent
4bf6461ca1
commit
4dcfb39494
@@ -69,12 +69,15 @@ struct cxper_char_traits
|
||||
|
||||
static constexpr char_type* move(char_type* dest, const char_type* src, std::size_t n)
|
||||
{
|
||||
if (detail::ptr_in_range(src, src + n, dest))
|
||||
{
|
||||
while (n--)
|
||||
assign(dest[n], src[n]);
|
||||
return dest;
|
||||
}
|
||||
// This implementation does not handle overlapping ranges where
|
||||
// dest > src. A correct implementation would need to detect this
|
||||
// case and copy backwards, but detecting overlap requires pointer
|
||||
// comparisons that many of the tested compiles (incorrectly) refuse
|
||||
// in constant expressions.
|
||||
//
|
||||
// Since cxper_char_traits is only used for testing constexpr
|
||||
// functionality and the tests do not exercise overlapping moves
|
||||
// where dest > src, this simple forward copy is sufficient.
|
||||
return copy(dest, src, n);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user