Skip to content

Commit f18c0b2

Browse files
committed
Replace the implementation of cxper_char_traits::move() with a simpler one
Reason: See the new code comment.
1 parent 094337b commit f18c0b2

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

test/constexpr_tests.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,15 @@ struct cxper_char_traits
6969

7070
static constexpr char_type* move(char_type* dest, const char_type* src, std::size_t n)
7171
{
72-
if (detail::ptr_in_range(src, src + n, dest))
73-
{
74-
while (n--)
75-
assign(dest[n], src[n]);
76-
return dest;
77-
}
72+
// This implementation does not handle overlapping ranges where
73+
// dest > src. A correct implementation would need to detect this
74+
// case and copy backwards, but detecting overlap requires pointer
75+
// comparisons that many of the tested compiles (incorrectly) refuse
76+
// in constant expressions.
77+
//
78+
// Since cxper_char_traits is only used for testing constexpr
79+
// functionality and the tests do not exercise overlapping moves
80+
// where dest > src, this simple forward copy is sufficient.
7881
return copy(dest, src, n);
7982
}
8083

0 commit comments

Comments
 (0)