libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

default.pass.cpp (1504B)


      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 && c++17
     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 
     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     (void)it;
     36     }
     37 };
     38 
     39 template <typename T>
     40 struct test_trivial<T, false> {
     41 void operator ()() const {}
     42 };
     43 #endif
     44 
     45 
     46 int main()
     47 {
     48     {
     49     typedef std::istream_iterator<int> T;
     50     T it;
     51     assert(it == T());
     52 #if TEST_STD_VER >= 11
     53     constexpr T it2;
     54     (void)it2;
     55 #endif
     56     }
     57 
     58 #if TEST_STD_VER > 14
     59     test_trivial<int>()();
     60     test_trivial<char>()();
     61     test_trivial<double>()();
     62     test_trivial<S>()();
     63     test_trivial<std::string>()();
     64 #endif
     65 }