Skip to content

Commit ff23b25

Browse files
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
1 parent d6181bd commit ff23b25

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

modules/juce_core/text/juce_CharPointer_UTF8.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class CharPointer_UTF8 final
4848
public:
4949
using CharType = char;
5050

51+
// Standard iterator traits for compatibility with STL algorithms
52+
using value_type = juce_wchar;
53+
using pointer = juce_wchar*;
54+
using reference = juce_wchar; // Note: returns by value since this is a proxy iterator
55+
using iterator_category = std::input_iterator_tag;
56+
using difference_type = std::ptrdiff_t;
57+
5158
explicit CharPointer_UTF8 (const CharType* rawPointer) noexcept
5259
: data (const_cast<CharType*> (rawPointer))
5360
{

0 commit comments

Comments
 (0)