From 358087847109758101
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,4441c5f6d7843223
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-09-04 16:37:55 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: sa_schreuder@wanadoo.nl (Sjoerd Schreuder)
Newsgroups: comp.std.c++
Subject: Re: C++0x Wish List (explicit class)
Date: Wed, 4 Sep 2002 23:37:54 +0000 (UTC)
Organization: Euronet Internet
Lines: 40
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <3D768036.3B2B9386@wanadoo.nl>
References: <3D48C729.40503@spamnot.codeweavers.com> <ehdlkuo9gkcu69b6og2aup9o63knu7tpra@4ax.com> <8c8b368d.0208060921.43e9e9d5@posting.google.com> <aiphem$9e5$1@acs2.byu.edu> <3D589892.3050008@spamnot.codeweavers.com> <8c8b368d.0208150528.2bc34601@posting.google.com> <ajjk97$3pb$1@acs2.byu.edu> <8c8b368d.0208220503.1c974370@posting.google.com> <ak3eve$4n1$1@acs2.byu.edu> <vhGu8zAcrVZ9EwzA@robinton.demon.co.uk> <umpnmctkahdoaa@corp.supernews.com> <a56a01a1.0209031231.78d784e6@posting.google.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: mail2news.demon.co.uk 1031182675 15489 10.0.0.1 (4 Sep 2002 23:37:55 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 4 Sep 2002 23:37:55 +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 17mjib-00041g-00
	for mail2news@news.news.demon.net; Wed, 04 Sep 2002 23:37:53 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id JAA23378; Thu, 5 Sep 2002 09:37:45 +1000 (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-Accept-Language: en
X-Newsgroups: comp.std.c++
X-NNTP-Posting-Date: Wed, 04 Sep 2002 23:48:06 MEST
Xref: archiver1.google.com comp.std.c++:13614

Adam Peterson wrote:
> If I could mark a class explicit to suppress conversion
> operators I don't specify, but somehow still get the compiler
> ctor/asmts, I'd use explicit on every class.

I get tired writing the 'standard' implementations for member functions
all the time. swap(), strong exception safe operator=(), operator+()
in terms of operator+=(). It's all in the books and could (should) be
generated automatically.

So here is my draft of a draft of a proposal.

Let's reuse the keyword 'default'! After a member declaration, 'default'
forces a compiler to generate the standard definition. This doesn't break
any code, as default is already a keyword and it will be introduced
at a place in the grammar it is not allowed at this moment.

As soon as 'standard' implementations for certain functions are established,
they could be added to the list of default-able functions.

explicit class Foo
{
  private:
    int a;
  public:
    Foo() : a(42) {} // do not want the default here
    Foo(const Foo &) default;
    const Foo &operator = (const Foo &) default;

    void swap(Foo &) default;  // I wish....
};

Sjoerd Schreuder

---
[ 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                       ]



