home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!titan!lpi!pkt
- From: pkt@lpi.liant.com (Scott Turner)
- Subject: Re: Question about temporaries
- Message-ID: <1993Jan25.163150.24449@lpi.liant.com>
- Sender: pkt@lpi (Scott Turner)
- Organization: Liant Software Corporation
- References: <C1DtoB.FJ3@fiu.edu>
- Date: Mon, 25 Jan 1993 16:31:50 GMT
- Lines: 36
-
- In article <C1DtoB.FJ3@fiu.edu>, feathers@serss0 (Michael Feathers) writes:
- >
- > Has the ANSI committee done any more work of the lifetime of temporaries?
- > I'm very curious about this aspect of the emerging standard.
-
- At the Boston meeting last November, some straw votes were taken to get
- the sense of the committee of the whole. IMO there was a clear leader
- among the possibilities which seemed viable at the time. Unfortunately
- no prize was awarded. :-) 38 voted that the following was acceptable,
- and none voted that it was unacceptable.
-
- Temporaries are normally destroyed at the end of the statement
- in which they are created. The exception is that temporaries
- created within a branch of a conditional (?:) operator are destroyed
- when that branch is completed (and analogously for && and ||).
-
- I would say that the committee was ready to compromise and decide on this
- except for one thing. Nearly all of the discussion has assumed that we
- know what is a "temporary". When asked directly regarding the formal
- argument x in the function
- class C { ... C (const C&); ... };
- void f(class C x) { ... use x ... }
- most people would say x is _not_ a temporary. On the other hand, a very
- popular implementation of C++ gives x the same extended lifetime as a
- temporary. Also, more than one example presented in favor of long-lived
- temporaries has actually needed long-lived formal arguments! If I recall
- correctly, an example was
- String x, y;
- char *z;
- extern char *f(String);
- z = f(x+y);
- --
- Prescott K. Turner, Jr.
- Liant Software Corp. (developers of LPI languages)
- 959 Concord St., Framingham, MA 01701 USA (508) 872-8700
- UUCP: uunet!lpi!pkt Internet: pkt@lpi.liant.com
-