From -8073183003420993917 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,6a0e273cd04a6fa1 X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2002-01-14 11:18:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail From: Pete Becker Newsgroups: comp.std.c++ Subject: Re: new meaning of explicit keyword Date: Mon, 14 Jan 2002 19:17:08 GMT Organization: Dinkumware, Ltd Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: <3C3F961A.AFDD9708@acm.org> References: <92ce342f.0201100428.49e3dd92@posting.google.com> <3C3DE3E6.F27385B2@acm.org> <3C3E11E4.E454ABB0@acm.org> <92ce342f.0201110304.3045ea38@posting.google.com> X-Trace: mail2news.demon.co.uk 1011035833 mail2news:3155 mail2news mail2news.demon.co.uk X-Complaints-To: abuse@demon.net X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Date: 12 Jan 2002 01:48:31 GMT X-Accept-Language: en Lines: 42 Xref: archiver1.google.com comp.std.c++:9027 Chris McClelland wrote: > > I understand your concern, Pete. > > I think the justification for support of explicit casts is partly > exactly the same as that for explicit construction, but also, since > explicit construction is already part of the language, symmetry > arguments provide further justification. But that's a false analogy. A single argument constructor does two distinct things: it creates objects (in the same way as a multi-argument constructor) and it converts values. If you don't want both, you use explicit to eliminate the latter. The sole reason for having a conversion operator is to convert values. Explicit conversion operators are simply a mechanism for requiring casts. > > In a language as large and complex as C++, it helps understandability > if the feature set is symmetric - having features which are included > in one context and not in another (for no good reason) is just one > more syntactic rule to learn about the language. Add to that the > ever-increasing importance of templates and generic programming, and > symmetry becomes not only desirable, but actually vital - the addition > (to ISO14882) of default constructors for fundamental types is a case > in point. > A couple of people have mentioned templates as a reason for having explicit conversion operators, but so far I haven't seen anyone explain what this means. How do templates benefit from someone being able to say "if you want this conversion you must write a cast"? -- Pete Becker Dinkumware, Ltd. (http://www.dinkumware.com) --- [ 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.research.att.com/~austern/csc/faq.html ]