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 // <string> 11 12 // template<class charT, class traits, class Allocator> 13 // basic_istream<charT,traits>& 14 // getline(basic_istream<charT,traits>&& is, 15 // basic_string<charT,traits,Allocator>& str); 16 17 #include <string> 18 #include <sstream> 19 #include <cassert> 20 21 #include "min_allocator.h" 22 23 int main() 24 { 25 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 26 { 27 std::string s("initial text"); 28 getline(std::istringstream(" abc\n def\n ghij"), s); 29 assert(s == " abc"); 30 } 31 { 32 std::wstring s(L"initial text"); 33 getline(std::wistringstream(L" abc\n def\n ghij"), s); 34 assert(s == L" abc"); 35 } 36 #if TEST_STD_VER >= 11 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\n def\n 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\n def\n ghij"), s); 47 assert(s == L" abc"); 48 } 49 #endif 50 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 51 } 52