tiny-utf8
tiny-utf8 copied to clipboard
compiling error
error now in tinyutf-8: include\libs\tinyutf8\tinyutf8.h|2360|error: cannot increment value of type 'const value_type[LITLEN]' (aka 'const ValueType[LITLEN]')|
here:
...
while( it != end && str_len ){
if( *it != *str )
return false;
----> HERE ---> ++it, ++str, --str_len; } return !str_len; }
Hey,
thanks for your message, this is most likely due to very strict warnings and warnings that are converted into errors (perhabys by -Werror) by your compiler. The code could be adapted however, in case this information still doesn't help you solve your problem.
Thanks, Jakob
Because of this, tiny-utf8 won't compile with Emscripten for Wasm.
It looks like we can just change it to a normal for-loop with an index, correct?
template<size_type LITLEN>
bool starts_with( const value_type (&str)[LITLEN] ) const noexcept {
size_type str_len = str[LITLEN-1] ? LITLEN : LITLEN-1;
const_iterator it = cbegin(), end = cend();
while( it != end && str_len ){
if( *it != *str )
return false;
++it, ++str, --str_len;
}
return !str_len;
}
So just change to this, I think?
template<size_type LITLEN>
bool starts_with( const value_type (&str)[LITLEN] ) const noexcept {
size_type str_len = str[LITLEN-1] ? LITLEN : LITLEN-1;
const_iterator it = cbegin(), end = cend();
for(int i = 0; i < str_len && it != end; ++i,++it) {
if( *it != str[i] )
return false;
}
return !str_len;
}
Or change to this:
template<size_type LITLEN>
bool starts_with( const value_type (&str)[LITLEN] ) const noexcept {
size_type str_len = str[LITLEN-1] ? LITLEN : LITLEN-1;
const_iterator it = cbegin(), end = cend();
const value_type* s = str;
while( it != end && str_len ){
if( *it != *s )
return false;
++it, ++s, --str_len;
}
return !str_len;
}