xref: /llvm-project/libcxx/test/std/input.output/iostream.format/std.manip/resetiosflags.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
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 // <iomanip>
10 
11 // T1 resetiosflags(ios_base::fmtflags mask);
12 
13 #include <iomanip>
14 #include <istream>
15 #include <ostream>
16 #include <cassert>
17 
18 template <class CharT>
19 struct testbuf
20     : public std::basic_streambuf<CharT>
21 {
22     testbuf() {}
23 };
24 
25 int main()
26 {
27     {
28         testbuf<char> sb;
29         std::istream is(&sb);
30         assert(is.flags() & std::ios_base::skipws);
31         is >> std::resetiosflags(std::ios_base::skipws);
32         assert(!(is.flags() & std::ios_base::skipws));
33     }
34     {
35         testbuf<char> sb;
36         std::ostream os(&sb);
37         assert(os.flags() & std::ios_base::skipws);
38         os << std::resetiosflags(std::ios_base::skipws);
39         assert(!(os.flags() & std::ios_base::skipws));
40     }
41     {
42         testbuf<wchar_t> sb;
43         std::wistream is(&sb);
44         assert(is.flags() & std::ios_base::skipws);
45         is >> std::resetiosflags(std::ios_base::skipws);
46         assert(!(is.flags() & std::ios_base::skipws));
47     }
48     {
49         testbuf<wchar_t> sb;
50         std::wostream os(&sb);
51         assert(os.flags() & std::ios_base::skipws);
52         os << std::resetiosflags(std::ios_base::skipws);
53         assert(!(os.flags() & std::ios_base::skipws));
54     }
55 }
56