This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: basic_string<> - operator+
- To: Ryszard Kabatek <kabatek@chemie.uni-halle.de>
- Subject: Re: basic_string<> - operator+
- From: Benjamin Kosnik <bkoz@cygnus.com>
- Date: Fri, 25 Jun 1999 01:40:16 -0700 (PDT)
- cc: libstdc++@sourceware.cygnus.com
> My proposal:
> create an empty string -> call reserve -> append __lhs -> append __rhs.
. . . does not avoid the call to _M_mutate in the case of const _CharT*: I
don't see any advantage, and an added complexity. Time it in a loop: I
believe you'll agree with me.
This may be a win though, in the case of the single _CharT:
template<typename _CharT, typename _Traits, typename _Alloc>
inline basic_string<_CharT, _Traits, _Alloc>
operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>&
__rhs)
{
basic_string<_CharT, _Traits, _Alloc> __str(__rhs);
__str.insert(__str.begin(), __lhs);
return __str;
}
-benjamin