Nikolas Klauser 425620ccdd [libc++] Implement P0980R1 (constexpr std::string)
Reviewed By: #libc, ldionne

Spies: daltenty, sdasgup3, ldionne, arichardson, MTC, ChuanqiXu, mehdi_amini, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes, tatianashp, rdzhabarov, teijeong, cota, dcaballe, Chia-hungDuan, wrengr, wenzhicui, arphaman, Mordante, miscco, Quuxplusone, smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D110598
2022-04-27 12:25:34 +02:00

47 lines
1.0 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
#include <cassert>
#include <string>
#include "test_macros.h"
struct Incomplete;
template<class T> struct Holder { T t; };
template<class T>
struct Charlike {
char ch_;
TEST_CONSTEXPR Charlike(char ch) : ch_(ch) {}
TEST_CONSTEXPR operator char() const { return ch_; }
};
TEST_CONSTEXPR_CXX20 bool test() {
std::string s;
Charlike<Holder<Incomplete> > a[] = {'m', 'a', 'h', 'i'};
s.append(a, a+4);
s.assign(a, a+4);
s.insert(s.begin(), a, a+4);
s.replace(s.begin(), s.begin()+4, a, a+4);
assert(s == "mahimahi");
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}