Topic: basic_string operator+()
Author: bkline%occs.nlm.nih.gov (Bob Kline Phoenix Contract)
Date: 1995/05/23 Raw View
The draft for the Strings library has an odd description of operator+
in section 21.1.1.10.1, where it says:
template<class charT, class traits, class Allocator>
basic_string<charT,traits,Allocator>
operator+(const basic_string<charT,traits,Allocator>& lhs,
const basic_string<charT,traits,Allocator>& rhs);
Returns lhs.append(rhs).
If you look back as 21.1.1.8.2, basic_string::append, you see that
basic_string::append() is a non-const member function, which means
that it can't be used to implement operator+(), for which lhs is
a const object. It wouldn't make sense anyway, because that would
duplicate the functionality of basic_string::operator+= (see
21.1.1.8.1). Don't we want operator+ to create an entirely new
object, not just append to lhs?
--
/*----------------------------------------------------------------------*/
/* Bob Kline Stream International */
/* bob_kline@stream.com formerly Corporate Software, Inc. */
/* voice: (703) 522-0820 x-311 fax: (703) 522-5407 */
/*----------------------------------------------------------------------*/