Re: icu4c api proposal: clone() for public c++ classes where missing
Markus Scherer <[email protected]>
| Newsgroups | gmane.comp.lib.icu.general |
|---|---|
| Organization | IBM |
| Message-ID | <[email protected]> |
Markus Scherer wrote:
> I propose to add clone() functions (and copy constructors/assignment
> operators where missing) to the following classes and their subclasses:
>
> (common)
> - ForwardCharacterIterator
> This one is a base class to CharacterIterator.
> FwdCI has no clone() but CI does, and it returns a CI*.
> I propose to add the one function FwdCI *FwdCI::clone().
This does not work as proposed. FwdCI cannot have a clone() function with a different return type
than CharacterIterator because some of our compilers do not support covariant return types (which
simply means they do not support exactly this kind of thing).
There are two options that I see:
1. Do nothing for ForwardCharacterIterator.
If in the future all then-supported compilers support covariant
return types, then we can add a clone() function at that time.
2. Add a clone() function by a different name,
like cloneForwardCharacterIterator(), and implement it in
CharacterIterator by calling CI::clone().
This would emphasize the anomaly that we (I) created when I added
ForwardCharacterIterator as a new base class to the existing
CharacterIterator, and would have to continue to be supported even
when compilers are all updated and this hack is not necessary any more.
I propose to 1. not add any kind of clone() to ForwardCharacterIterator now.
markus