From 95c8c1edec261bc42c8fdc1d89fb694bdcf089b5 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Wed, 17 Dec 2025 12:47:20 +0100 Subject: [PATCH] Replace the implementation of cxper_char_traits::move() with a simpler one Reason: See the new code comment. --- test/constexpr_tests.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/constexpr_tests.hpp b/test/constexpr_tests.hpp index c748ec7..a60add9 100644 --- a/test/constexpr_tests.hpp +++ b/test/constexpr_tests.hpp @@ -69,12 +69,16 @@ 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 are not allowed in constant expressions when + // the pointers point to unrelated objects (e.g., a string literal + // and the static_string's internal buffer). + // + // 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); }