Topic: question about typeid
Author: "Anon" <spamme@lots.moderated.news.pipex.net>
Date: Fri, 16 Feb 2001 08:22:37 GMT Raw View
Is the following code valid?
void foo()
{
int i;
typeid( i );
}
I don't have typeinfo included, so I don't know
what std::type_info is. However, I'm just throwing
the result of typeid away.
---
[ 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: "Algorithms" <witzel@qwest.net>
Date: Fri, 16 Feb 2001 18:11:10 GMT Raw View
5.2.8 p6
"If the header <typeinfo> (18.5.1) is not included prior to a use of typeid,
the program is ill-formed."
Is that what your wondering? ..
--
Algorithms
http://www.cs.ircnetworks.com
"Anon" <spamme@lots.moderated.news.pipex.net> wrote in message
news:3a8c8cb8_1@news.nwlink.com...
| Is the following code valid?
|
| void foo()
| {
| int i;
| typeid( i );
| }
|
| I don't have typeinfo included, so I don't know
| what std::type_info is. However, I'm just throwing
| the result of typeid away.
|
|
|
| ---
| [ 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. ]
|
---
[ 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: "James Kuyper Jr." <kuyper@wizard.net>
Date: Fri, 16 Feb 2001 21:54:06 GMT Raw View
Anon wrote:
>
> Is the following code valid?
>
> void foo()
> {
> int i;
> typeid( i );
> }
>
> I don't have typeinfo included, so I don't know
> what std::type_info is. However, I'm just throwing
> the result of typeid away.
All you need to know is that typeid() returns a value. C++ always allows
you to ignore a returned value. As long as the typeid expression itself
is valid, and it seems to be, this should work. Did you remember to
#include <typeinfo>?
---
[ 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: "William M. Miller" <wmmiller@MailAndNews.com>
Date: Fri, 16 Feb 2001 21:55:48 GMT Raw View
>===== Original Message From "Anon" <spamme@lots.moderated.news.pipex.net>
=====
>Is the following code valid?
>
>void foo()
>{
> int i;
> typeid( i );
>}
>
>I don't have typeinfo included, so I don't know
>what std::type_info is. However, I'm just throwing
>the result of typeid away.
It doesn't matter what you do or don't do with the result. The
Standard is clear in 5.2.8p6:
If the header <typeinfo> (18.5.1) is not included prior to a
use of typeid, the program is ill-formed.
Your example is a use of typeid, even though the result is ignored.
-- William M. Miller
---
[ 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. ]