One of the pain points with using ICU C++ API is that some of our subclass functions return pointer-to-base-class, just because 20 years ago some compilers didn't support covariant return types.
(FYI: In Java, covariant return types are supported since Java 5: )
For example, UnicodeSet clone() and freeze() return pointers to the UnicodeFunctor base class, so you can't just write
Instead you have to
Could we change our clone(), freeze(), and similar functions to return same-as-this types?
Andy wrote in a PR comment:
This regular expression: (.*).*clone( finds a fair number of clones with casts, where the cast could potentially be removed.
( I get 228 matches, a number of them false positives.