]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
Vendor import of libc++ trunk r302418:
[FreeBSD/FreeBSD.git] / test / std / iterators / stream.iterators / ostreambuf.iterator / types.pass.cpp
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 // <iterator>
11
12 // template <class charT, class traits = char_traits<charT> >
13 // class ostreambuf_iterator
14 //   : public iterator<output_iterator_tag, void, void, void, void>
15 // {
16 // public:
17 //   typedef charT                          char_type;
18 //   typedef traits                         traits_type;
19 //   typedef basic_streambuf<charT, traits> streambuf_type;
20 //   typedef basic_ostream<charT, traits>   ostream_type;
21 //   ...
22
23 #include <iterator>
24 #include <string>
25 #include <type_traits>
26
27 #include "test_macros.h"
28
29 int main()
30 {
31     typedef std::ostreambuf_iterator<char> I1;
32 #if TEST_STD_VER <= 14
33     static_assert((std::is_convertible<I1,
34         std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
35 #else
36     static_assert((std::is_same<I1::iterator_category, std::output_iterator_tag>::value), "");
37     static_assert((std::is_same<I1::value_type, void>::value), "");
38     static_assert((std::is_same<I1::difference_type, void>::value), "");
39     static_assert((std::is_same<I1::pointer, void>::value), "");
40     static_assert((std::is_same<I1::reference, void>::value), "");
41 #endif
42     static_assert((std::is_same<I1::char_type, char>::value), "");
43     static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
44     static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
45     static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
46
47     typedef std::ostreambuf_iterator<wchar_t> I2;
48 #if TEST_STD_VER <= 14
49     static_assert((std::is_convertible<I2,
50         std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
51 #else
52     static_assert((std::is_same<I2::iterator_category, std::output_iterator_tag>::value), "");
53     static_assert((std::is_same<I2::value_type, void>::value), "");
54     static_assert((std::is_same<I2::difference_type, void>::value), "");
55     static_assert((std::is_same<I2::pointer, void>::value), "");
56     static_assert((std::is_same<I2::reference, void>::value), "");
57 #endif
58     static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
59     static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
60     static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
61     static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
62 }