Topic: Feature request: Forward declaration of typedefs


Author: "Wilka" <jvyxn@evghnyvfgvp.pbz>
Date: Sun, 21 Jan 2001 06:04:59 GMT
Raw View
things like "class std::string;" are illegal because std::string isn't a
class, but it's such a common thing to want to do (mostly for user defined
types) that it probably should be possible. Obvious you can't use 'class'
for this purpose, but I can't think of a reason not to allow, e.g.

typename std::string;

struct something
{
   something(const std::string& str);
    std::string foo() const;
};

It could also be extended to work with enums, and possibly nested types,
e.g.

typename an_enum;

class a_class;
typename a_class::an_enum;
typename a_class::another_class;




--
- Wilka
(address rot13 encoded)

---
[ 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                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]





Author: Dennis Yelle <dennis51@jps.net>
Date: Mon, 22 Jan 2001 19:19:39 GMT
Raw View
Wilka wrote:
>
> things like "class std::string;" are illegal because std::string isn't a
> class, but it's such a common thing to want to do (mostly for user defined
> types) that it probably should be possible. Obvious you can't use 'class'
> for this purpose, but I can't think of a reason not to allow, e.g.
>
> typename std::string;
>
> struct something
> {
>    something(const std::string& str);
>     std::string foo() const;
> };

Allowing that would cause significant changes to compilers,
because of the way name mangling works.  Currently,
the something constructor above does not take a class with the
name string, it takes a template class named basic_string....

A simpler solution to this problem is to allow this:
   #include <stdfwd>
All we need to do is to come up with a list of things that <stdfwd>
should include.  Obviously string should be in there, but what else?

Dennis Yelle
--
I am a computer programmer and I am looking for a job.
There is a link to my resume here:
http://table.jps.net/~vert/

---
[ 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                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]