This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

### 460. Default modes missing from basic_fstream member specifications

Section: 29.10 [file.streams] Status: CD1 Submitter: Ben Hutchings Opened: 2004-04-01 Last modified: 2017-06-15

Priority: Not Prioritized

View all other issues in [file.streams].

View all issues with CD1 status.

Discussion:

The second parameters of the non-default constructor and of the open member function for basic_fstream, named "mode", are optional according to the class declaration in 27.8.1.11 [lib.fstream]. The specifications of these members in 27.8.1.12 [lib.fstream.cons] and 27.8.1.13 lib.fstream.members] disagree with this, though the constructor declaration has the "explicit" function-specifier implying that it is intended to be callable with one argument.

Proposed resolution:

In 29.10.5.2 [fstream.cons], change

      explicit basic_fstream(const char* s, ios_base::openmode mode);

to

      explicit basic_fstream(const char* s,
                             ios_base::openmode mode = ios_base::in|ios_base::out);

In 29.10.5.4 [fstream.members], change

      void open(const char*s, ios_base::openmode mode);

to

      void open(const char*s,
                ios_base::openmode mode = ios_base::in|ios_base::out);