Path: utzoo!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!elroy.jpl.nasa.gov!jarthur!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.lang.c++ Subject: Re: Overloaded operator dot? Message-ID: <71246@microsoft.UUCP> Date: 12 Mar 91 22:06:05 GMT References: <11152@jarthur.Claremont.EDU> Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Organization: Microsoft Corp., Redmond WA Lines: 29 In article <11152@jarthur.Claremont.EDU> dfoster@jarthur.Claremont.EDU (Derek R. Foster) writes: |I have heard a few references lately to the possibility of adding to c++ |an overloadable operator dot. I have a few questions about this: | |1) Is the committee seriously considering this right now, or is this just | a suggestion? If they are considering it, what are the chances of it | passing? I wrote this up as a formal request for review some months ago. Bjarne wrote me last week saying that the idea was still under consideration, and that he likes the idea. How seriously anyone else takes the idea I cannot say. I am encourage by the number of people finding good uses for it recently. |2) If this suggestion is actually used, what is the syntax to invoke | the normal (un-overloaded) dot operator? Operator dot works very similarly to operator point, as a starting point. Like the other overloaded operators, operator dot isn't ever implicitly invoked -- if you don't explicitly type a dot, you don't get an invocation of operator dot. Smart reference classes, like smart pointer classes, are typically pretty simple things. Thus, the easiest way to keep from invoking operator dot when you don't want it [during the construction of your smart reference class] is simply to specify the required members without adornment -- which gives you the standard implicit "this->" prefix. Other "tricks" to avoid "accidentally" getting the overloaded operator dot include implementing some of your smart reference class in a private superclass, and only introduce the operator dot in the subclass, or perhaps doing a (&smartRef)->doSomething();