Home | History | Annotate | Download | only in string.io
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // UNSUPPORTED: c++98, c++03
     11 
     12 // <string>
     13 
     14 // template<class charT, class traits, class Allocator>
     15 //   basic_istream<charT,traits>&
     16 //   getline(basic_istream<charT,traits>&& is,
     17 //           basic_string<charT,traits,Allocator>& str, charT delim);
     18 
     19 #include <string>
     20 #include <sstream>
     21 #include <cassert>
     22 
     23 #include "min_allocator.h"
     24 
     25 int main()
     26 {
     27     {
     28         std::string s("initial text");
     29         getline(std::istringstream(" abc*  def*   ghij"), s, '*');
     30         assert(s == " abc");
     31     }
     32     {
     33         std::wstring s(L"initial text");
     34         getline(std::wistringstream(L" abc*  def*   ghij"), s, L'*');
     35         assert(s == L" abc");
     36     }
     37     {
     38         typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
     39         S s("initial text");
     40         getline(std::istringstream(" abc*  def*   ghij"), s, '*');
     41         assert(s == " abc");
     42     }
     43     {
     44         typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
     45         S s(L"initial text");
     46         getline(std::wistringstream(L" abc*  def*   ghij"), s, L'*');
     47         assert(s == L" abc");
     48     }
     49 }
     50