default.pass.cpp revision c10e963f3d17c11a34ff4da9810940e63b130a7d
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://bugs.llvm.org/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 is a constexpr constructor. 21 22#include <iterator> 23#include <cassert> 24#include <string> 25 26#include "test_macros.h" 27 28struct 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 45int 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} 64