1094. Replace "unspecified-bool-type" by "explicit operator bool() const" in I/O library

Section: 31.5.4.4 [iostate.flags] Status: C++11 Submitter: P.J. Plauger Opened: 2009-03-24 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [iostate.flags].

View all issues with C++11 status.

Discussion:

Addresses JP 65 and JP 66 [CD1]

Switch from "unspecified-bool-type" to "explicit operator bool() const".

Replace operator unspecified-bool-type() const;" with explicit operator bool() const;

[ Batavia (2009-05): ]

We agree with the proposed resolution. Move to Review.

[ 2009 Santa Cruz: ]

Moved to Ready.

Proposed resolution:

Change the synopis in 31.5.4 [ios]:

explicit operator unspecified-bool-type bool() const;

Change 31.5.4.4 [iostate.flags]:

explicit operator unspecified-bool-type bool() const;

-1- Returns: !fail() If fail() then a value that will evaluate false in a boolean context; otherwise a value that will evaluate true in a boolean context. The value type returned shall not be convertible to int.

[Note: This conversion can be used in contexts where a bool is expected (e.g., an if condition); however, implicit conversions (e.g., to int) that can occur with bool are not allowed, eliminating some sources of user error. One possible implementation choice for this type is pointer-to-member. -- end note]