xref: /llvm-project/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp (revision 6e1dcc9335116f650d68cdbed12bbb34a99b2d9b)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <string>
10 
11 // Call erase(const_iterator position) with an iterator from another container
12 
13 // REQUIRES: has-unix-headers
14 // UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03
15 
16 #include <string>
17 
18 #include "check_assertion.h"
19 #include "min_allocator.h"
20 
21 template <class S>
test()22 void test() {
23   S l1("123");
24   S l2("123");
25   typename S::const_iterator i = l2.begin();
26   TEST_LIBCPP_ASSERT_FAILURE(
27       l1.erase(i), "string::erase(iterator) called with an iterator not referring to this string");
28 }
29 
main(int,char **)30 int main(int, char**) {
31   test<std::string>();
32   test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
33 
34   return 0;
35 }
36