This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Specialize string::replace
- From: Philip Martin <philip at codematters dot co dot uk>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: libstdc++ at gcc dot gnu dot org, bkoz at redhat dot com, ncm at cantrip dot org
- Date: 25 Mar 2002 02:49:24 +0000
- Subject: Re: [PATCH] Specialize string::replace
- References: <3C9E85CC.4030806@unitus.it>
Paolo Carlini <pcarlini@unitus.it> writes:
> now that we have branched I'd like to proceed for 3.2 with the
> implementation of the string class improvements outlined
> by Nathan. Below you will find a patch which specializes
>
> template<class _InputIterator>
> basic_string&
> replace(iterator __i1, iterator __i2,
> _InputIterator __k1, _InputIterator __k2)
>
> for the common cases of _InputIterator as pointer, const pointer,
> iterator and const_iterator. It is overall quite straightforward
> and indeed I have verified that it enables the optimization of the
> assign, insert and replace members which have the source data
> specified in terms of iterators. My only doubt is about the ugly
> reinterpret_cast: is there any cleaner way to obtain from a _CharT*,
> iterator or const_iterator, the required const _CharT* ?
iterator is __normal_iterator<pointer, basic_string> and has a base()
member function that returns a pointer. pointer is the basic_string's
allocater's pointer type. Is this sufficient? (Even if it is not
sufficient, it is probably necessary before casting.)
Similarly, const_iterator is __normal_iterator<const_pointer, basic_string>
and here the base() member function returns a const_pointer.
Do you really have to cast _CharT* to get const _CharT*? Isn't that a
standard conversion?
--
Philip