mirror of
https://github.com/clang-retro/llvm.git
synced 2026-12-04 08:09:27 -08:00
[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:
1 parent
6e078f9804
commit
425620ccdd
211 files changed
+2291
-2074
No files matched your search
+5
-3
@@ -6,10 +6,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// <string>
|
||||
|
||||
// template <class T>
|
||||
// basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17
|
||||
// basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20
|
||||
|
||||
#include <string>
|
||||
#include <string>
|
||||
@@ -71,7 +73,7 @@ test_npos(S s, SV sv, typename S::size_type pos, S expected)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
@@ -203,7 +205,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+5
-3
@@ -6,11 +6,13 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string& append(initializer_list<charT> il);
|
||||
// basic_string& append(initializer_list<charT> il); // constexpr since C++20
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
@@ -18,7 +20,7 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
std::string s("123");
|
||||
s.append({'a', 'b', 'c'});
|
||||
@@ -38,7 +40,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+5
-3
@@ -6,10 +6,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// <string>
|
||||
|
||||
// template<class InputIterator>
|
||||
// basic_string& append(InputIterator first, InputIterator last);
|
||||
// basic_string& append(InputIterator first, InputIterator last); // constexpr since C++20
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
@@ -52,7 +54,7 @@ test_exceptions(S s, It first, It last)
|
||||
}
|
||||
#endif
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
@@ -259,7 +261,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+5
-3
@@ -6,9 +6,11 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string<charT,traits,Allocator>& append(const charT* s);
|
||||
// basic_string<charT,traits,Allocator>& append(const charT* s); // constexpr since C++20
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
@@ -26,7 +28,7 @@ test(S s, const typename S::value_type* str, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), "", S());
|
||||
@@ -83,7 +85,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+5
-3
@@ -6,10 +6,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string<charT,traits,Allocator>&
|
||||
// append(const charT* s, size_type n);
|
||||
// append(const charT* s, size_type n); // constexpr since C++20
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
@@ -27,7 +29,7 @@ test(S s, const typename S::value_type* str, typename S::size_type n, S expected
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), "", 0, S());
|
||||
@@ -92,7 +94,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+5
-3
@@ -6,9 +6,11 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// <string>
|
||||
|
||||
// void push_back(charT c)
|
||||
// void push_back(charT c) // constexpr since C++20
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
@@ -31,7 +33,7 @@ test(S s, typename S::value_type c, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), 'a', S(1, 'a'));
|
||||
@@ -63,7 +65,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+5
-3
@@ -6,10 +6,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string<charT,traits,Allocator>&
|
||||
// append(size_type n, charT c);
|
||||
// append(size_type n, charT c); // constexpr since C++20
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
@@ -26,7 +28,7 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), 0, 'a', S());
|
||||
@@ -67,7 +69,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string<charT,traits,Allocator>&
|
||||
// append(const basic_string<charT,traits>& str);
|
||||
// append(const basic_string<charT,traits>& str); // constexpr since C++20
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
@@ -26,7 +28,7 @@ test(S s, S str, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), S(), S());
|
||||
@@ -92,7 +94,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+5
-3
@@ -6,10 +6,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string<charT,traits,Allocator>&
|
||||
// append(const basic_string<charT,traits>& str, size_type pos, size_type n = npos);
|
||||
// append(const basic_string<charT,traits>& str, size_type pos, size_type n = npos); // constexpr since C++20
|
||||
// the "= npos" was added for C++14
|
||||
|
||||
#include <string>
|
||||
@@ -71,7 +73,7 @@ test_npos(S s, S str, typename S::size_type pos, S expected)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), S(), 0, 0, S());
|
||||
@@ -140,7 +142,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+5
-3
@@ -6,10 +6,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: LIBCXX-AIX-FIXME
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string<charT,traits,Allocator>&
|
||||
// append(basic_string_view<charT,traits> sv);
|
||||
// append(basic_string_view<charT,traits> sv); // constexpr since C++20
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -27,7 +29,7 @@ test(S s, SV sv, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
bool test() {
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
@@ -86,7 +88,7 @@ int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user