Topic: possible extension -- typeof(expr)


Author: phalpern@truffle.ultranet.com (Pablo Halpern)
Date: 1996/03/08
Raw View
tjb839@zacatecas.optimum.com (Tim Boemker) wrote:

>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

Actually, I'm surprized that the notation s.iterator is not valid. If
iterator were a static variable or function, instead of a nested class
or typedef, then it WOULD be valid. Has there been any discusion of
permitting this syntax? It seems like it would be easy to implement
(just an extention of the current scope-resolution rules) and would
solve many of the problems that typeof() addresses. The example would
look like this:

   set<foo, less<foo> > s;
   for(s.iterator i = s.begin(); i != s.end(); i++)
   //  ^^^^^^^^^^ why isn't this currently valid?
      // do something

-------------------------------------------------------------
Pablo Halpern                   phalpern@truffle.ultranet.com

I am self-employed. Therefore, my opinions *do* represent
those of my employer.
---
[ To submit articles: try just posting with your news-reader.
                      If that fails, use mailto:std-c++@ncar.ucar.edu
  FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu.
]