From -377314397465302737
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,2c058f2002bfcf32,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-02-11 20:05:19 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: acappellaguy@hotmail.com (A Cappella Guy)
Newsgroups: comp.std.c++
Subject: proposal: better support for IS_IMPLEMENTED_IN_TERMS_OF
Date: Wed, 12 Feb 2003 04:05:10 +0000 (UTC)
Lines: 85
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <110220031511499473%acappellaguy@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: mail2news.demon.co.uk 1045022710 20231 10.0.0.1 (12 Feb 2003 04:05:10 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 12 Feb 2003 04:05:10 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.05)
	id 18io8y-0005GA-00
	for mail2news@news.news.demon.net; Wed, 12 Feb 2003 04:05:09 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id PAA03441; Wed, 12 Feb 2003 15:05:04 +1100 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ncar.ucar.edu
X-Newsgroups: comp.std.c++
X-User-Agent: Thoth/1.4.6 (Carbon/OS X)
X-NNTP-Posting-Date: Tue, 11 Feb 2003 18:11:53 EST
X-MailScanner: PASSED (v1.2.7 76222 h1BNBtEx008179 mailbox2.ucsd.edu)
X-Spam-Status: No, hits=1.2 required=5.0
	tests=FORGED_HOTMAIL_RCVD,INVALID_MSGID,SPAM_PHRASE_00_01,
	      USER_AGENT
	version=2.41
X-Spam-Level: *
Xref: archiver1.google.com comp.std.c++:17909

I apologize that I do not have a specific, detailed proposal in mind,
just a couple areas where I believe the language could help better
model the IS_IMPLEMENTED_IN_TERMS_OF relationship.  I'm hoping to open
up a dialogue.

1) Extend using.

I would like to see the using keyword bring selected methods of
privately-inherited or contained implementation classes into the main
interface of a class.  Something like:

class Foo : private Bar {
public:
   using Bar::A;
   using Bar::B;
   using m_Impl.C;
   using m_Impl.D;
private:
   Impl m_Impl;
};

So you could take helper classes and have the compiler write member
functions that patch through to the selected instance, keeping others
private for the class's own use.

I suppose the following would theoretically be possible too:

class Foo {
public:
   using m_impl->A;
   using m_Impl->B;
private:
   Impl* m_Impl;
};

Though there would obviously be the restriction that Impl be fully
defined prior to the using directive.  This wouldn't help users of
pimpl who want to hide the private details of the class.  Also there
could be complications involving overloaded operator-> and such.

2) Public const, private non-const

Automatic support for publicizing the const members of an
implementation class, keeping non-const members private.  Here I have
an actual example:

class Directory {
public:
   Directory(const std::string& path);
   void Refresh();
   using const m_Contents;
private:
   std::vector<Node> m_Contents;
};

This is a situation where the class has the authority to change the
vector of files/directories/symlinks/etc in the directory because it
should reflect reality and the Refresh command is a controlled way to
do it safely, but the user should be able only to read it.  I actually
have a similar class to this one, and ended up having to replicate and
manually pipe through all the const std::vector methods.  It wasn't a
huge deal, 12 member functions I think, but the typing was so automatic
it got me to thinking maybe the compiler could be directed to do this
for me.

Another way to phrase the above solution, for those who prefer private
inheritance, could be:

class Directory : private std::vector<Node> {
public:
   Directory(const std::string& path);
   void Refresh();
   using const std::vector<Node>;
}

Any thoughts?

 -- A Cappella Guy

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



