15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <regex>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // template <class BidirectionalIterator> class sub_match;
125a83710eSEric Fiselier 
135a83710eSEric Fiselier // operator string_type() const;
145a83710eSEric Fiselier 
155a83710eSEric Fiselier #include <regex>
165a83710eSEric Fiselier #include <cassert>
17fd5ceb22SMarshall Clow #include "test_macros.h"
185a83710eSEric Fiselier 
main(int,char **)192df59c50SJF Bastien int main(int, char**)
205a83710eSEric Fiselier {
215a83710eSEric Fiselier     {
225a83710eSEric Fiselier         typedef char CharT;
235a83710eSEric Fiselier         typedef std::sub_match<const CharT*> SM;
245a83710eSEric Fiselier         SM sm = SM();
255a83710eSEric Fiselier         SM::string_type str = sm;
265a83710eSEric Fiselier         assert(str.empty());
275a83710eSEric Fiselier         const CharT s[] = {'1', '2', '3', 0};
285a83710eSEric Fiselier         sm.first = s;
295a83710eSEric Fiselier         sm.second = s + 3;
305a83710eSEric Fiselier         sm.matched = true;
315a83710eSEric Fiselier         str = sm;
325a83710eSEric Fiselier         assert(str == std::string("123"));
335a83710eSEric Fiselier     }
34*f4c1258dSLouis Dionne #ifndef TEST_HAS_NO_WIDE_CHARACTERS
355a83710eSEric Fiselier     {
365a83710eSEric Fiselier         typedef wchar_t CharT;
375a83710eSEric Fiselier         typedef std::sub_match<const CharT*> SM;
385a83710eSEric Fiselier         SM sm = SM();
395a83710eSEric Fiselier         SM::string_type str = sm;
405a83710eSEric Fiselier         assert(str.empty());
415a83710eSEric Fiselier         const CharT s[] = {'1', '2', '3', 0};
425a83710eSEric Fiselier         sm.first = s;
435a83710eSEric Fiselier         sm.second = s + 3;
445a83710eSEric Fiselier         sm.matched = true;
455a83710eSEric Fiselier         str = sm;
465a83710eSEric Fiselier         assert(str == std::wstring(L"123"));
475a83710eSEric Fiselier     }
48*f4c1258dSLouis Dionne #endif
492df59c50SJF Bastien 
502df59c50SJF Bastien   return 0;
515a83710eSEric Fiselier }
52