Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


492.typeid constness inconsistent with example

Section:7.6.1.8  [expr.typeid]    Status:CD1    Submitter:Ron Natalie    Date:15 Dec 2004

[Voted into WP at April, 2006 meeting.]

There is an inconsistency between the normative text insection 7.6.1.8 [expr.typeid] andthe example that follows.

Here is the relevant passage (starting with paragraph 4):

Whentypeid is applied to atype-id, the resultrefers to astd::type_info object representing the type of thetype-id. If the type of thetype-id is a referencetype, the result of thetypeid expression refers to astd::type_info object representing the referenced type.

The top-level cv-qualifiers of the lvalue expression or thetype-id that is the operand oftypeid are alwaysignored.

and the example:

    typeid(D) == typeid(const D&); // yields true

The second paragraph above says the “type-id that isthe operand”. This would beconst D&. Inthis case, theconst is not at the top-level (i.e.,applied to the operand itself).

By a strict reading, the above should yieldfalse.

My proposal is that the strict reading of the normative test is correct.The example is wrong. Different compilers here give differentanswers.

Proposed resolution (April, 2005):

Change the second sentence of 7.6.1.8 [expr.typeid] paragraph 4as follows:

If the type of thetype-id is a referenceto a possiblycv-qualified type, the result of thetypeid expressionrefers to astd::type_info object representing thecv-unqualified referenced type.



[8]ページ先頭

©2009-2026 Movatter.jp