TITLE: argument for return type of operator = (Newsgroups: comp.lang.c++, 2 Jan 2 97) [ This picks up a discussion about whether the return type of operator=() should be void or T&. The usage of this operator for built-in types follows the latter. -adc ] KOENIG: ark@research.att.com (Andrew Koenig) [snip] > > b) a class whose assignment operator returns void > > fails to meet the requirements for elements of some > > kinds of standard library containers. [snip] HELLER: heller@utdallas.edu (Steve Heller) > Could you give me an example of this problem? KOENIG: Sure. Suppose you define a class T, with an eye toward being able to create a vector object (where vector is as defined in the STL and, presumabely, in the eventual standard C++ library). Then the question is: What operations do you have to define for your class in order to guarantee that vector can be created? The C++ draft answers this question by publishing some tables of requirements, and by saying that your class T must meet particular subsets of those requirements in order to be able to do particular things with a vector. Among those requirements is the so-called Assignable requirement, which says that if t and u are objects of type T, then the expression t=u must yield a T& and afterwards, t must be a copy of u. So, if you define a class T with an assignment operator that returns void, the standard library is not required to implement vector correctly.