Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / re / re.submatch / re.submatch.members / str.pass.cpp
blobffdcbaabb44f7f7750594f8d7551b09bb8888a02
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 //===----------------------------------------------------------------------===//
9 // <regex>
11 // template <class BidirectionalIterator> class sub_match;
13 // string_type str() const;
15 #include <regex>
16 #include <cassert>
17 #include "test_macros.h"
19 int main(int, char**)
22 typedef char CharT;
23 typedef std::sub_match<const CharT*> SM;
24 SM sm = SM();
25 SM::string_type str = sm.str();
26 assert(str.empty());
27 const CharT s[] = {'1', '2', '3', 0};
28 sm.first = s;
29 sm.second = s + 3;
30 sm.matched = true;
31 str = sm.str();
32 assert(str == std::string("123"));
34 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
36 typedef wchar_t CharT;
37 typedef std::sub_match<const CharT*> SM;
38 SM sm = SM();
39 SM::string_type str = sm.str();
40 assert(str.empty());
41 const CharT s[] = {'1', '2', '3', 0};
42 sm.first = s;
43 sm.second = s + 3;
44 sm.matched = true;
45 str = sm.str();
46 assert(str == std::wstring(L"123"));
48 #endif
50 return 0;