1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <string> 10 // ... manipulating sequences of any non-array trivial standard-layout types. 11 12 // XFAIL: FROZEN-CXX03-HEADERS-FIXME 13 14 #include <string> 15 #include "test_traits.h" 16 17 struct NotTrivial { 18 NotTrivial() : value(3) {} 19 int value; 20 }; 21 22 struct NotStandardLayout { 23 public: 24 NotStandardLayout() : one(1), two(2) {} 25 int sum() const { return one + two; } // silences "unused field 'two' warning" 26 int one; 27 28 private: 29 int two; 30 }; 31 32 void f() { 33 { 34 // array 35 typedef char C[3]; 36 static_assert(std::is_array<C>::value, ""); 37 std::basic_string<C, test_traits<C> > s; 38 // expected-error-re@string:* {{static assertion failed{{.*}}Character type of basic_string must not be an array}} 39 } 40 41 { 42 // not trivial 43 static_assert(!std::is_trivial<NotTrivial>::value, ""); 44 std::basic_string<NotTrivial, test_traits<NotTrivial> > s; 45 // expected-error-re@string:* {{static assertion failed{{.*}}Character type of basic_string must be trivial}} 46 } 47 48 { 49 // not standard layout 50 static_assert(!std::is_standard_layout<NotStandardLayout>::value, ""); 51 std::basic_string<NotStandardLayout, test_traits<NotStandardLayout> > s; 52 // expected-error-re@string:* {{static assertion failed{{.*}}Character type of basic_string must be standard-layout}} 53 } 54 } 55