home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!destroyer!sol.ctr.columbia.edu!eff!world!pkturner
- From: pkturner@world.std.com (Prescott K Turner)
- Subject: Re: Temporary variables and unnamed objects
- Message-ID: <BszD04.7Ao@world.std.com>
- Keywords: Constructors,temporary,unnamed
- Organization: The World Public Access UNIX, Brookline, MA
- References: <1992Aug10.143831.29819@bnr.ca>
- Date: Fri, 14 Aug 1992 15:43:15 GMT
- Lines: 38
-
- Rene Tio writes:
- > On one hand, the ARM says the only operations allowed on temporaries are
- > assignments and binding of references, on the other hand, code such as:
- >
- > class Object {
- > Object(int) { ... }
- > void doSomething(void) { ... }
- > };
- >
- > Object a(2), b(3);
- > Object c = a + b / 2
- >
- > where the temporary created by (a + b) is operated on by "/".
-
- That's an omission in the ARM.
-
- > In addition the ARM does not make clear whether
- >
- > Object(1)
- >
- > is a temporary, but only says it is an "unnamed object".
-
- When Object(1) is an unnamed object, it is a temporary.
-
- > Finally, the ARM says that the constructor is not true a callable function
- > which has no return type, yet cfront allows:
- >
- > Object(3).doSomething()
- >
- > which implies that constructors *DO* return values (i.e., the object being
- > constructed,) and that it returns an lvalue.
-
- Here, you've made the common error of mistaking Object(3) for a function
- call, when it's actually an explicit conversion (ARM 5.2.3).
- --
- Prescott K. Turner, Jr.
- 13 Burning Tree Rd., Natick, Massachusetts USA
- Internet: pkturner@world.std.com
-