blob: c5bae9a14bb3e8309d304632cce8d5096ff2a00b [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
Eric Fiselier6d959822016-12-14 21:22:48 +000010// Usage of is_trivially_constructible is broken with these compilers.
Eric Fiselierb7fd0be2017-02-17 08:37:03 +000011// See https://bugs.llvm.org/show_bug.cgi?id=31016
Eric Fiselier4a435412016-12-15 05:41:07 +000012// XFAIL: clang-3.7, apple-clang-7, apple-clang-7.0
Eric Fiselier6d959822016-12-14 21:22:48 +000013
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000014// <iterator>
15
16// class istream_iterator
17
Marshall Clowe9d03062015-04-16 21:36:54 +000018// constexpr istream_iterator();
Eric Fiselier6d959822016-12-14 21:22:48 +000019// C++17 says: If is_trivially_default_constructible_v<T> is true, then this
Stephan T. Lavavej16e2ba12017-01-18 20:10:25 +000020// constructor is a constexpr constructor.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000021
22#include <iterator>
23#include <cassert>
Eric Fiselier6d959822016-12-14 21:22:48 +000024#include <string>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000025
Eric Fiselierd24c4652016-06-14 21:31:42 +000026#include "test_macros.h"
27
Eric Fiselier6d959822016-12-14 21:22:48 +000028struct S { S(); }; // not constexpr
29
30#if TEST_STD_VER > 14
31template <typename T, bool isTrivial = std::is_trivially_default_constructible_v<T>>
32struct test_trivial {
33void operator ()() const {
34 constexpr std::istream_iterator<T> it;
35 }
36};
37
38template <typename T>
39struct test_trivial<T, false> {
40void operator ()() const {}
41};
42#endif
43
44
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000045int main()
46{
Marshall Clowe9d03062015-04-16 21:36:54 +000047 {
48 typedef std::istream_iterator<int> T;
49 T it;
50 assert(it == T());
Eric Fiselierd24c4652016-06-14 21:31:42 +000051#if TEST_STD_VER >= 11
Marshall Clowe9d03062015-04-16 21:36:54 +000052 constexpr T it2;
53#endif
54 }
Eric Fiselier84acb1e2016-06-01 21:35:39 +000055
Eric Fiselier6d959822016-12-14 21:22:48 +000056#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 Hinnantbc8d3f92010-05-11 19:42:16 +000063}