🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Give operator. a chance

#3061
From: Dan Holmsand
Date: Mon, 22 Jan 1996 17:44
34 lines
2007 bytes
Is operator.() banned from the standards discussion?

Such a creature would sure be nice to have, given the STL 
containers. Suppose that you have a list<string>, and lots of 
code looking like

  typedef list<string> stringlist;
  /* ....... */
  for (stringlist::iterator i = l.begin(); i != l.end(); i++)
	(*i).append(".");

Then you decide that you want to put something else into the 
list. If you decide not to derive from string (e.g. using a smart 
pointer instead), there is no alternative to rewriting all the 
functions refering to type stringlist.

The only way to retain flexibility now, as far as I can see, is 
to refrain from using constructs like (*i).function(), using 
smart pointer imitating wrappers and (*i)->function() 
consequently instead. But this is kind of messy...

Ideally, operator.() should allow you to have all the things 
inheritance allows you to have, except for storage. I.e. a class 
with operator.() should behave just as its "base class", but be 
allowed to override suitable functions.

Why isn't this possible? What's the catch?

Dan Holmsand
dan@et.se
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <3102AD11.1663@et.se>
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern
From: Dan Holmsand <dan@et.se>
Newsgroups: comp.std.c++
Subject: Give operator. a chance
Date: 22 Jan 1996 09:44:26 PST
Organization: Affdrsvdrlden
Approved: austern@isolde.mti.sgi.com
Message-ID: <3102AD11.1663@et.se>
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: Sun, 21 Jan 1996 22:16:01 +0100
X-Mailer: Mozilla 2.0b6 (WinNT; I)
X-Url: http://dogbert.lbl.gov/~matt/std-c++/policy.html
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMQPNCUy4NqrwXLNJAQGoyQIAoLyGVSD5Dq4K2BkTHgJDynKd/Pjxb9zF
 vMkfirRHP4usBz9cYcbIBPUp9XdxIok36wfcdAfou8jRsM07OXh5jA==
 =diHi
Originator: austern@isolde.mti.sgi.com