blob: 1878cd02ca38e228eb588bd7fc6d8b37b56507e7 [file] [log] [blame]
Marshall Clow4a6f3c42018-03-21 00:36:05 +00001//===----------------------------------------------------------------------===//
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// <string>
11// ... manipulating sequences of any non-array trivial standard-layout types.
12
13#include <string>
14#include "test_traits.h"
15
16struct NotTrivial {
17 NotTrivial() : value(3) {}
18 int value;
19};
20
21struct NotStandardLayout {
22public:
23 NotStandardLayout() : one(1), two(2) {}
24 int sum() const { return one + two; } // silences "unused field 'two' warning"
25 int one;
26private:
27 int two;
28};
29
30int main()
31{
32 {
33// array
34 typedef char C[3];
35 static_assert(std::is_array<C>::value, "");
36 std::basic_string<C, test_traits<C> > s;
37// expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must not be an array"}}
38 }
39
40 {
41// not trivial
42 static_assert(!std::is_trivial<NotTrivial>::value, "");
43 std::basic_string<NotTrivial, test_traits<NotTrivial> > s;
44// expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must be trivial"}}
45 }
46
47 {
48// not standard layout
49 static_assert(!std::is_standard_layout<NotStandardLayout>::value, "");
50 std::basic_string<NotStandardLayout, test_traits<NotStandardLayout> > s;
51// expected-error-re@string:* {{static_assert failed{{.*}} "Character type of basic_string must be standard-layout"}}
52 }
53}