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