Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++] Implement P2438R2 (std::string::substr() &&)
This doesn't affect our ABI because `std::string::substr()` isn't in the dylib and the mangling of `substr() const` and `substr() const&` are different. Reviewed By: ldionne, Mordante, var-const, avogelsgesang, #libc Spies: arphaman, huixie90, libcxx-commits Differential Revision: https://reviews.llvm.org/D131668
- Loading branch information
1 parent
001d186
commit 29378ab
Showing
10 changed files
with
543 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
libcxx/test/libcxx/strings/basic.string/string.cons/debug.iterator.substr.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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> | ||
|
||
// Check that basic_string(basic_string&&, size_type, Allocator) and | ||
// basic_string(basic_string&&, size_type, size_type, Allocator) inserts the container into the debug database | ||
|
||
// REQUIRES: has-unix-headers | ||
// UNSUPPORTED: !libcpp-has-debug-mode, c++03 | ||
|
||
#include <cassert> | ||
#include <string> | ||
|
||
#include "check_assertion.h" | ||
|
||
int main(int, char**) { | ||
using namespace std::string_literals; | ||
|
||
{ | ||
std::string s = {"Banane"s, 1}; | ||
auto i = s.begin(); | ||
assert(i[0] == 'a'); | ||
TEST_LIBCPP_ASSERT_FAILURE(i[5], "Attempted to subscript an iterator outside its valid range"); | ||
} | ||
{ | ||
std::string s = {"Banane"s, 0, 5}; | ||
auto i = s.begin(); | ||
assert(i[0] == 'B'); | ||
TEST_LIBCPP_ASSERT_FAILURE(i[5], "Attempted to subscript an iterator outside its valid range"); | ||
} | ||
{ | ||
std::string s = {"long long string so no SSO"s, 21}; | ||
auto i = s.begin(); | ||
assert(i[0] == 'o'); | ||
TEST_LIBCPP_ASSERT_FAILURE(i[5], "Attempted to subscript an iterator outside its valid range"); | ||
} | ||
{ | ||
std::string s = {"long long string so no SSO"s, 0, 5}; | ||
auto i = s.begin(); | ||
assert(i[0] == 'l'); | ||
TEST_LIBCPP_ASSERT_FAILURE(i[5], "Attempted to subscript an iterator outside its valid range"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.