Title
Type deduction from a bool context
Status
cd2
Section
13.10.3.4 [temp.deduct.conv]
Submitter
John Spicer

Created on 2004-12-17.00:00:00 last changed 143 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2010-02-15.00:00:00

Proposed resolution (February, 2010):

This issue is resolved by the resolution of issue 976.

Date: 2005-04-15.00:00:00

Notes from the April, 2005 meeting:

The CWG observed that there is nothing special about either bool or the context in the example above; instead, it will be a problem wherever a copy occurs, because cv-qualification is always dropped in a copy operation. This appears to be a case where the conversion deduction rules are not properly symmetrical with the rules for arguments. The example should be accepted.

Date: 2004-12-17.00:00:00

An expression used in an if statement is implicitly converted to type bool (8.5 [stmt.select]). According to the rules of template argument deduction for conversion functions given in 13.10.3.4 [temp.deduct.conv], the following example is ill-formed:

    struct X {
      template<class T> operator const T&() const;
    };
    int main()
    {
      if( X() ) {}
    }

Following the logic in 13.10.3.4 [temp.deduct.conv], A is bool and P is const T (because cv-qualification is dropped from P before the reference is removed), and deduction fails.

It's not clear whether this is the intended outcome or not.

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2743
2010-03-29 00:00:00adminsetstatus: tentatively ready -> cd2
2010-02-16 00:00:00adminsetmessages: + msg2514
2010-02-16 00:00:00adminsetstatus: drafting -> tentatively ready
2005-05-01 00:00:00adminsetmessages: + msg1168
2005-05-01 00:00:00adminsetstatus: open -> drafting
2004-12-17 00:00:00admincreate