Debian Codegraph @

libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/string.move.mode.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10
11 // <sstream>
12
13 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
14 // class basic_istringstream
15
16 // explicit basic_istringstream(basic_string<char_type, traits_type, allocator_type>&& s, ios_base::openmode which = ios_base::in);
17
18 #include <sstream>
19 #include <cassert>
20
21 #include "make_string.h"
22 #include "test_macros.h"
23
24 #define STR(S) MAKE_STRING(CharT, S)
25
26 template <class CharT>
27 static void test() {
28 {
29 std::basic_string<CharT> s(STR("testing"));
30 const std::basic_istringstream<CharT> ss(std::move(s));
31 assert(ss.str() == STR("testing"));
32 }
33 {
34 std::basic_string<CharT> s(STR("testing"));
35 const std::basic_istringstream<CharT> ss(std::move(s), std::ios_base::binary);
36 assert(ss.str() == STR("testing"));
37 }
38 }
39
40 int main(int, char**) {
41 test<char>();
42 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
43 test<wchar_t>();
44 #endif
45 return 0;
46 }