[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
This commit is contained in:
Nikolas Klauser committed 2022-04-27 12:25:34 +02:00
1 parent 6e078f9804
commit 425620ccdd
211 files changed
+2291 -2074

No files matched your search

@@ -6,9 +6,11 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: LIBCXX-AIX-FIXME
// <string>
// size_type copy(charT* s, size_type n, size_type pos = 0) const;
// size_type copy(charT* s, size_type n, size_type pos = 0) const; // constexpr since C++20
#include <string>
#include <stdexcept>
@@ -19,7 +21,7 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(S str, typename S::value_type* s, typename S::size_type n,
typename S::size_type pos)
{
@@ -33,7 +35,7 @@ test(S str, typename S::value_type* s, typename S::size_type n,
assert(S::traits_type::eq(cs[pos+r], s[r]));
}
#ifndef TEST_HAS_NO_EXCEPTIONS
else
else if (!TEST_IS_CONSTANT_EVALUATED)
{
try
{
@@ -49,7 +51,7 @@ test(S str, typename S::value_type* s, typename S::size_type n,
#endif
}
bool test() {
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
char s[50];
@@ -184,7 +186,7 @@ int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
static_assert(test());
#endif
return 0;