1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // template<class charT, class traits, class Allocator>
12 // basic_istream<charT,traits>&
13 // operator>>(basic_istream<charT,traits>& is,
14 // basic_string<charT,traits,Allocator>& str);
20 #include "min_allocator.h"
21 #include "test_macros.h"
23 template <template <class> class Alloc
>
25 using S
= std::basic_string
<char, std::char_traits
<char>, Alloc
<char> >;
27 std::istringstream
in("a bc defghij");
32 assert(in
.peek() == ' ');
36 assert(in
.peek() == ' ');
41 assert(in
.peek() == 'g');
48 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
50 using WS
= std::basic_string
<wchar_t, std::char_traits
<wchar_t>, Alloc
<wchar_t> >;
51 std::wistringstream
in(L
"a bc defghij");
52 WS
s(L
"initial text");
56 assert(in
.peek() == L
' ');
60 assert(in
.peek() == L
' ');
65 assert(in
.peek() == L
'g');
74 #ifndef TEST_HAS_NO_EXCEPTIONS
78 is
.exceptions(std::ios::failbit
);
84 } catch (std::ios::failure
const&) {
96 is
.exceptions(std::ios::eofbit
);
102 } catch (std::ios::failure
const&) {
111 #endif // TEST_HAS_NO_EXCEPTIONS
114 int main(int, char**) {
115 test_string
<std::allocator
>();
116 #if TEST_STD_VER >= 11
117 test_string
<min_allocator
>();