🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: possible extension -- typeof(expr)

#3626
From: Raja R Harinath
Date: Sat, 09 Mar 1996 00:06
47 lines
2505 bytes
In article <u9ag1t3njg.fsf@yorick.cygnus.com> 
jason@cygnus.com (Jason Merrill) writes:
> 
> >>>>> Tim Boemker <tjb839@zacatecas.optimum.com> writes:
> 
> > Many times in working with STL I've wished for a new operator to return
> > the type of an expression, much the same way sizeof returns the size of
> > an expression.
> 
> > It would allow programs like the following, for example:
> 
> >    set<foo, less<foo> > s;
> >    for(typeof(s)::iterator i = s.begin(); i != s.end(); i++)
> >       // do something
> 
> > I suppose this must have been considered by now.  Has anything come of
> > it?
> 
> It has come up in the committee, but no-one has made a formal proposal, and
> it's too late now.

Instead of introducing a new keyword `typeof', what about allowing this
usage:

  set <foo, less<foo> > s;
  for (typename s.iterator i = s.begin(); ... )
       ^^^^^^^^ ^^^
       |        |
      (1)      (2)

1. Extending `typename' to a non-template context to allow (2).

2. Accessing a member type/typedef using the `.' syntax (and against an
   object) instead of the `::' syntax against a typename.

(1) above solves the parsing problem associated with allowing syntax (2)
independently, and uses an existing keyword (and extends its meaning,
without, IMO, overloading it).

- Hari
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]
Technical Details
Message-ID: <d93f7jp4d6.fsf@hecto.cs.umn.edu>
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
References: <199603061757.AA17403@zacatecas.optimum.com> <u9ag1t3njg.fsf@yorick.cygnus.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
From: harinath@cs.umn.edu (Raja R Harinath)
Newsgroups: comp.std.c++
Subject: Re: possible extension -- typeof(expr)
Date: 08 Mar 1996 16:06:31 PST
Organization: Dept of Comp Sc, Univ of Minnesota
Approved: austern@isolde.mti.sgi.com
Message-ID: <d93f7jp4d6.fsf@hecto.cs.umn.edu>
References: <199603061757.AA17403@zacatecas.optimum.com>
 <u9ag1t3njg.fsf@yorick.cygnus.com>
NNTP-Posting-Host: isolde.mti.sgi.com
Mime-Version: 1.0 (generated by tm-edit 7.46)
X-Original-Date: 08 Mar 1996 17:11:33 -0600
X-Newsreader: September Gnus v0.50/Emacs 19.30
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMUDLpEy4NqrwXLNJAQH3JwIAsgxqz2iiYrhBBLrQk5JC26Q5+dZ+tRNg
 ++Hp5XWAtBlesYLLl/r9gKpzYghDp+h+swE5ep5VvOjizf2vcciHsw==
 =Yyqv
Originator: austern@isolde.mti.sgi.com