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
11 #include <cassert>
12 #include <string>
13
14 #include "test_macros.h"
15
16 struct Incomplete;
17 template<class T> struct Holder { T t; };
18
19 template<class T>
20 struct Charlike {
21 char ch_;
CharlikeCharlike22 TEST_CONSTEXPR Charlike(char ch) : ch_(ch) {}
operator charCharlike23 TEST_CONSTEXPR operator char() const { return ch_; }
24 };
25
test()26 TEST_CONSTEXPR_CXX20 bool test() {
27 std::string s;
28 Charlike<Holder<Incomplete> > a[] = {'m', 'a', 'h', 'i'};
29 s.append(a, a+4);
30 s.assign(a, a+4);
31 s.insert(s.begin(), a, a+4);
32 s.replace(s.begin(), s.begin()+4, a, a+4);
33 assert(s == "mahimahi");
34
35 return true;
36 }
37
main(int,char **)38 int main(int, char**)
39 {
40 test();
41 #if TEST_STD_VER > 17
42 static_assert(test());
43 #endif
44
45 return 0;
46 }
47