🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #111

Is coercion to a reference defined?

#111
From: Mayan Moudgill
Date: Sun, 06 Sep 1992 18:29
22 lines
747 bytes
I'm trying to implement an embedded list template class.
It looks something like:

template <class T> class emList {
   ...
   emList *    _next;
   T           _value;
   ...
};

I'd like to define TWO functions:

     operator T () { return _value;}

and
     operator T& () { return _value;}

Is the second definition legal?
How would the compiler resolve them?

:)
Mayan
Technical Details
Message-ID: <1992Sep6.182905.6603@cs.cornell.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!sdd.hp.com!usc!rpi!batcomputer!cornell!moudgill

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!sdd.hp.com!usc!rpi!batcomputer!cornell!moudgill
From: moudgill@cs.cornell.edu ( Mayan Moudgill)
Subject: Is coercion to a reference defined?
Message-ID: <1992Sep6.182905.6603@cs.cornell.edu>
Organization: Cornell Univ. CS Dept, Ithaca NY 14853
Date: Sun, 6 Sep 1992 18:29:05 GMT
Lines: 22