Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Eric Fiselier | 6d95982 | 2016-12-14 21:22:48 +0000 | [diff] [blame] | 10 | // Usage of is_trivially_constructible is broken with these compilers. |
Eric Fiselier | b7fd0be | 2017-02-17 08:37:03 +0000 | [diff] [blame^] | 11 | // See https://bugs.llvm.org/show_bug.cgi?id=31016 |
Eric Fiselier | 4a43541 | 2016-12-15 05:41:07 +0000 | [diff] [blame] | 12 | // XFAIL: clang-3.7, apple-clang-7, apple-clang-7.0 |
Eric Fiselier | 6d95982 | 2016-12-14 21:22:48 +0000 | [diff] [blame] | 13 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 14 | // <iterator> |
| 15 | |
| 16 | // class istream_iterator |
| 17 | |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 18 | // constexpr istream_iterator(); |
Eric Fiselier | 6d95982 | 2016-12-14 21:22:48 +0000 | [diff] [blame] | 19 | // C++17 says: If is_trivially_default_constructible_v<T> is true, then this |
Stephan T. Lavavej | 16e2ba1 | 2017-01-18 20:10:25 +0000 | [diff] [blame] | 20 | // constructor is a constexpr constructor. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | |
| 22 | #include <iterator> |
| 23 | #include <cassert> |
Eric Fiselier | 6d95982 | 2016-12-14 21:22:48 +0000 | [diff] [blame] | 24 | #include <string> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 25 | |
Eric Fiselier | d24c465 | 2016-06-14 21:31:42 +0000 | [diff] [blame] | 26 | #include "test_macros.h" |
| 27 | |
Eric Fiselier | 6d95982 | 2016-12-14 21:22:48 +0000 | [diff] [blame] | 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 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | int main() |
| 46 | { |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 47 | { |
| 48 | typedef std::istream_iterator<int> T; |
| 49 | T it; |
| 50 | assert(it == T()); |
Eric Fiselier | d24c465 | 2016-06-14 21:31:42 +0000 | [diff] [blame] | 51 | #if TEST_STD_VER >= 11 |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 52 | constexpr T it2; |
| 53 | #endif |
| 54 | } |
Eric Fiselier | 84acb1e | 2016-06-01 21:35:39 +0000 | [diff] [blame] | 55 | |
Eric Fiselier | 6d95982 | 2016-12-14 21:22:48 +0000 | [diff] [blame] | 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 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 63 | } |