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

43 lines
910 B
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
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <string>
// constexpr bool ends_with(charT x) const noexcept;
#include <string>
#include <cassert>
#include "test_macros.h"
constexpr bool test() {
{
typedef std::string S;
S s1 {};
S s2 { "abcde", 5 };
ASSERT_NOEXCEPT(s1.ends_with('e'));
assert (!s1.ends_with('e'));
assert (!s1.ends_with('x'));
assert ( s2.ends_with('e'));
assert (!s2.ends_with('x'));
}
return true;
}
int main(int, char**)
{
test();
static_assert(test());
return 0;
}