]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / iterators / stream.iterators / istream.iterator / istream.iterator.cons / default.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 // Usage of is_trivially_constructible is broken with these compilers.
11 // See https://llvm.org/bugs/show_bug.cgi?id=31016
12 // XFAIL: clang-3.7, apple-clang-7, apple-clang-7.0
13
14 // <iterator>
15
16 // class istream_iterator
17
18 // constexpr istream_iterator();
19 // C++17 says: If is_trivially_default_constructible_v<T> is true, then this
20 //    constructor shall beis a constexpr constructor.
21
22 #include <iterator>
23 #include <cassert>
24 #include <string>
25
26 #include "test_macros.h"
27
28 struct S { S(); }; // not constexpr
29
30 #if TEST_STD_VER > 14
31 template <typename T, bool isTrivial = std::is_trivially_default_constructible_v<T>>
32 struct test_trivial {
33 void operator ()() const {
34     constexpr std::istream_iterator<T> it;
35     }
36 };
37
38 template <typename T>
39 struct test_trivial<T, false> {
40 void operator ()() const {}
41 };
42 #endif
43
44
45 int main()
46 {
47     {
48     typedef std::istream_iterator<int> T;
49     T it;
50     assert(it == T());
51 #if TEST_STD_VER >= 11
52     constexpr T it2;
53 #endif
54     }
55
56 #if TEST_STD_VER > 14
57     test_trivial<int>()();
58     test_trivial<char>()();
59     test_trivial<double>()();
60     test_trivial<S>()();
61     test_trivial<std::string>()();
62 #endif
63 }