460. Default modes missing from basic_fstream member specifications

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

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 30.9.5.1 [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 30.9.5.3 [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);