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

### 2131. Member function getline taking a string as parameter

Section: 31.7.5.4 [istream.unformatted] Status: NAD Submitter: Loïc Joly Opened: 2012-03-05 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [istream.unformatted].

View all issues with NAD status.

Discussion:

I think the following code should be legal:

>     void f(std::istream& is)
>     {
>       std::string s;
>       is.getline(s); // Would be equivalent to std::getline(is, s)
>     }

[2013-04-20, Bristol]

Unanimous that this is a new feature request and not a issue.

Resolution: Tentatively NAD

Proposed resolution:

This wording is relative to N3376.

1. Change the class template `basic_istream` synopsis, 31.7.5.2 [istream], as indicated

   >     namespace std {
   >       template <class charT, class traits = char_traits<charT> >
   >       class basic_istream : virtual public basic_ios<charT,traits> {
   >       public:
   >         […]
   >         // 27.7.2.3 Unformatted input:
   >         […]
   >         basic_istream<charT,traits>& getline(char_type* s, streamsize n);
   >         basic_istream<charT,traits>& getline(char_type* s, streamsize n,
   >           char_type delim);
   >         template<class Allocator>
   >         basic_istream<charT,traits>& getline(basic_string<charT,traits,Allocator>& str);
   >         template<class Allocator>
   >         basic_istream<charT,traits>& getline(basic_string<charT,traits,Allocator>& str,
   >           char_type delim);
   >         […]
   >       };
   >     }

2. Insert the following two new prototype descriptions after 31.7.5.4 [istream.unformatted] paragraph 24:

   >     basic_istream<charT,traits>& getline(char_type* s, streamsize n);

   > > -24- Returns: `getline(s,n,widen('\n'))`

   >     template<class Allocator>
   >     basic_istream<charT,traits>& getline(basic_string<charT,traits,Allocator>& str);

   > > -??- Returns: `std::getline(*this, str)`

   >     template<class Allocator>
   >     basic_istream<charT,traits>& getline(basic_string<charT,traits,Allocator>& str, char_type delim);

   > > -??- Returns: `std::getline(*this, str, delim)`