[LoongArch] Supports FP_TO_SINT operation for fp16 (#118303)
[llvm-project.git] / libcxx / test / std / iterators / stream.iterators / ostreambuf.iterator / ostreambuf.iter.ops / failed.pass.cpp
blob665554d109616e285403d25489bd1224ec5fb3cf
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 //===----------------------------------------------------------------------===//
9 // <iterator>
11 // class ostreambuf_iterator
13 // bool failed() const throw();
15 #include <cassert>
16 #include <iterator>
17 #include <sstream>
19 #include "test_macros.h"
21 template <typename Char, typename Traits = std::char_traits<Char> >
22 struct my_streambuf : public std::basic_streambuf<Char,Traits> {
23 typedef typename std::basic_streambuf<Char,Traits>::int_type int_type;
24 typedef typename std::basic_streambuf<Char,Traits>::char_type char_type;
26 my_streambuf() {}
27 int_type sputc(char_type) { return Traits::eof(); }
30 int main(int, char**)
33 my_streambuf<char> buf;
34 std::ostreambuf_iterator<char> i(&buf);
35 i = 'a';
36 assert(i.failed());
38 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
40 my_streambuf<wchar_t> buf;
41 std::ostreambuf_iterator<wchar_t> i(&buf);
42 i = L'a';
43 assert(i.failed());
45 #endif
47 return 0;