//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // basic_istream& // getline(basic_istream& is, // basic_string& str); #include #include #include #include "min_allocator.h" int main() { { std::istringstream in(" abc\n def\n ghij"); std::string s("initial text"); getline(in, s); assert(in.good()); assert(s == " abc"); getline(in, s); assert(in.good()); assert(s == " def"); getline(in, s); assert(in.eof()); assert(s == " ghij"); } { std::wistringstream in(L" abc\n def\n ghij"); std::wstring s(L"initial text"); getline(in, s); assert(in.good()); assert(s == L" abc"); getline(in, s); assert(in.good()); assert(s == L" def"); getline(in, s); assert(in.eof()); assert(s == L" ghij"); } #if __cplusplus >= 201103L { typedef std::basic_string, min_allocator> S; std::istringstream in(" abc\n def\n ghij"); S s("initial text"); getline(in, s); assert(in.good()); assert(s == " abc"); getline(in, s); assert(in.good()); assert(s == " def"); getline(in, s); assert(in.eof()); assert(s == " ghij"); } { typedef std::basic_string, min_allocator> S; std::wistringstream in(L" abc\n def\n ghij"); S s(L"initial text"); getline(in, s); assert(in.good()); assert(s == L" abc"); getline(in, s); assert(in.good()); assert(s == L" def"); getline(in, s); assert(in.eof()); assert(s == L" ghij"); } #endif }