Compilation fails at juce_AccessibilityTextHelpers.h

After this commit,

xutility(1736,19): error : no matching constructor for initialization of 'juce::CharPointer_UTF8'
xutility(1582,18): message : in instantiation of default member initializer 'std::reverse_iterator<juce::CharPointer_UTF8>::current' requested here
concepts(102,8): message : in evaluation of exception specification for 'std::reverse_iterator<juce::CharPointer_UTF8>::reverse_iterator' needed here
concepts(102,8): message : while substituting template arguments into constraint expression here
concepts(105,33): message : while checking the satisfaction of concept 'constructible_from<std::reverse_iterator<juce::CharPointer_UTF8>>' requested here
concepts(105,33): message : while substituting template arguments into constraint expression here
concepts(245,40): message : (skipping 16 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
xutility(5175,23): message : in instantiation of variable template specialization 'std::_Memchr_in_find_is_safe<std::reverse_iterator<juce::CharPointer_UTF8>, unsigned int>' requested here
xutility(5206,31): message : in instantiation of function template specialization 'std::_Find_unchecked<std::reverse_iterator<juce::CharPointer_UTF8>, unsigned int>' requested here
juce_AccessibilityTextHelpers.h(164,72): message : in instantiation of function template specialization 'std::find<std::reverse_iterator<juce::CharPointer_UTF8>, unsigned int>' requested here
juce_AccessibilityTextHelpers.h(178,42): message : in instantiation of function template specialization 'juce::AccessibilityTextHelpers::findNextLineOffset(juce::CharPointer_UTF8, juce::CharPointer_UTF8, juce::CharPointer_UTF8, juce::AccessibilityTextHelpers::Direction, juce::AccessibilityTextHelpers::IncludeThisBoundary)::(anonymous class)::operator()<std::reverse_iterator<juce::CharPointer_UTF8>, std::reverse_iterator<juce::CharPointer_UTF8>>' requested here
juce_AccessibilityTextHelpers.h(228,41): message : in instantiation of function template specialization 'juce::AccessibilityTextHelpers::findNextLineOffset<juce::CharPointer_UTF8>' requested here
juce_CharPointer_UTF8.h(41,14): message : candidate constructor not viable: requires single argument 'rawPointer', but no arguments were provided
juce_CharPointer_UTF8.h(46,5): message : candidate constructor not viable: requires single argument 'other', but no arguments were provided

Here:

const auto rbegin   = std::make_reverse_iterator (ptr);
const auto rend     = std::make_reverse_iterator (begin);

reverse_iterator<Iter> requires Iter to be a LegacyBidirectionalIterator, which requires LegacyForwardIterator, which requires DefaultConstructible. Temporary fix:

CharPointer_UTF8() = default;

What compiler and flags are you using?

Ok, I’m rewriting this because the example I used yesterday actually fails on both compilers, I don’t know what happened before.

Compilation fails with Clang 13 on Windows and /std::C++20 or latest. As the error shows, it fails on the call to std::find, because CharPointer_UTF8 doesn’t satisfy the constraints required (default_initializable). I don’t know why MSVC allows it or why std::make_reverse_iterator doesn’t fail, but I’m using concepts everywhere so I can’t go back to C++17.

Thanks for reporting. A fix has been added on develop:

2 Likes