71 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// XFAIL: FROZEN-CXX03-HEADERS-FIXME10 11// <string>12// ... manipulating sequences of any non-array trivial standard-layout types.13 14#include <string>15#include <type_traits>16#include "test_traits.h"17 18struct NotTriviallyCopyable {19 int value;20 NotTriviallyCopyable& operator=(const NotTriviallyCopyable& other) {21 value = other.value;22 return *this;23 }24};25 26struct NotTriviallyDefaultConstructible {27 NotTriviallyDefaultConstructible() : value(3) {}28 int value;29};30 31struct NotStandardLayout {32public:33 NotStandardLayout() : one(1), two(2) {}34 int sum() const { return one + two; } // silences "unused field 'two' warning"35 int one;36 37private:38 int two;39};40 41void f() {42 {43 // array44 typedef char C[3];45 static_assert(std::is_array<C>::value, "");46 std::basic_string<C, test_traits<C> > s;47 // expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string must not be an array}}48 }49 50 {51 // not trivially copyable52 static_assert(!std::is_trivially_copyable<NotTriviallyCopyable>::value, "");53 std::basic_string<NotTriviallyCopyable, test_traits<NotTriviallyCopyable> > s;54 // expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string must be trivially copyable}}55 }56 57 {58 // not trivially default constructible59 static_assert(!std::is_trivially_default_constructible<NotTriviallyDefaultConstructible>::value, "");60 std::basic_string<NotTriviallyDefaultConstructible, test_traits<NotTriviallyDefaultConstructible> > s;61 // expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string must be trivially default constructible}}62 }63 64 {65 // not standard layout66 static_assert(!std::is_standard_layout<NotStandardLayout>::value, "");67 std::basic_string<NotStandardLayout, test_traits<NotStandardLayout> > s;68 // expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string must be standard-layout}}69 }70}71