From ff23b25e6a988150403f7e072d415f3b91136cac Mon Sep 17 00:00:00 2001 From: Quaylyn Rimer Date: Sun, 3 Aug 2025 23:56:08 -0600 Subject: [PATCH] Fix #946: Add standard iterator traits to CharPointer_UTF8 for compatibility with std algorithms - Added value_type, pointer, reference, iterator_category, and difference_type typedefs - Enables CharPointer_UTF8 to work with standard library algorithms like std::all_of - Uses input_iterator_tag as the most appropriate category for UTF-8 character iteration - Maintains full backward compatibility with existing code - Tested with both GCC and Clang compilers --- modules/juce_core/text/juce_CharPointer_UTF8.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/juce_core/text/juce_CharPointer_UTF8.h b/modules/juce_core/text/juce_CharPointer_UTF8.h index a13ff2cb7b0f..2d98b8d9c408 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF8.h +++ b/modules/juce_core/text/juce_CharPointer_UTF8.h @@ -48,6 +48,13 @@ class CharPointer_UTF8 final public: using CharType = char; + // Standard iterator traits for compatibility with STL algorithms + using value_type = juce_wchar; + using pointer = juce_wchar*; + using reference = juce_wchar; // Note: returns by value since this is a proxy iterator + using iterator_category = std::input_iterator_tag; + using difference_type = std::ptrdiff_t; + explicit CharPointer_UTF8 (const CharType* rawPointer) noexcept : data (const_cast (rawPointer)) {