chromium/third_party/libc++/src/include/regex

// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_REGEX
#define _LIBCPP_REGEX

/*
    regex synopsis

#include <compare>
#include <initializer_list>

namespace std
{

namespace regex_constants
{

enum syntax_option_type
{
    icase      = unspecified,
    nosubs     = unspecified,
    optimize   = unspecified,
    collate    = unspecified,
    ECMAScript = unspecified,
    basic      = unspecified,
    extended   = unspecified,
    awk        = unspecified,
    grep       = unspecified,
    egrep      = unspecified,
    multiline  = unspecified
};

constexpr syntax_option_type operator~(syntax_option_type f);
constexpr syntax_option_type operator&(syntax_option_type lhs, syntax_option_type rhs);
constexpr syntax_option_type operator|(syntax_option_type lhs, syntax_option_type rhs);

enum match_flag_type
{
    match_default     = 0,
    match_not_bol     = unspecified,
    match_not_eol     = unspecified,
    match_not_bow     = unspecified,
    match_not_eow     = unspecified,
    match_any         = unspecified,
    match_not_null    = unspecified,
    match_continuous  = unspecified,
    match_prev_avail  = unspecified,
    format_default    = 0,
    format_sed        = unspecified,
    format_no_copy    = unspecified,
    format_first_only = unspecified
};

constexpr match_flag_type operator~(match_flag_type f);
constexpr match_flag_type operator&(match_flag_type lhs, match_flag_type rhs);
constexpr match_flag_type operator|(match_flag_type lhs, match_flag_type rhs);

enum error_type
{
    error_collate    = unspecified,
    error_ctype      = unspecified,
    error_escape     = unspecified,
    error_backref    = unspecified,
    error_brack      = unspecified,
    error_paren      = unspecified,
    error_brace      = unspecified,
    error_badbrace   = unspecified,
    error_range      = unspecified,
    error_space      = unspecified,
    error_badrepeat  = unspecified,
    error_complexity = unspecified,
    error_stack      = unspecified
};

}  // regex_constants

class regex_error
    : public runtime_error
{
public:
    explicit regex_error(regex_constants::error_type ecode);
    regex_constants::error_type code() const;
};

template <class charT>
struct regex_traits
{
public:
    typedef charT                   char_type;
    typedef basic_string<char_type> string_type;
    typedef locale                  locale_type;
    typedef /bitmask_type/          char_class_type;

    regex_traits();

    static size_t length(const char_type* p);
    charT translate(charT c) const;
    charT translate_nocase(charT c) const;
    template <class ForwardIterator>
        string_type
        transform(ForwardIterator first, ForwardIterator last) const;
    template <class ForwardIterator>
        string_type
        transform_primary( ForwardIterator first, ForwardIterator last) const;
    template <class ForwardIterator>
        string_type
        lookup_collatename(ForwardIterator first, ForwardIterator last) const;
    template <class ForwardIterator>
        char_class_type
        lookup_classname(ForwardIterator first, ForwardIterator last,
                         bool icase = false) const;
    bool isctype(charT c, char_class_type f) const;
    int value(charT ch, int radix) const;
    locale_type imbue(locale_type l);
    locale_type getloc()const;
};

template <class charT, class traits = regex_traits<charT>>
class basic_regex
{
public:
    // types:
    typedef charT                               value_type;
    typedef traits                              traits_type;
    typedef typename traits::string_type        string_type;
    typedef regex_constants::syntax_option_type flag_type;
    typedef typename traits::locale_type        locale_type;

    // constants:
    static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
    static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
    static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
    static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
    static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
    static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
    static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
    static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
    static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
    static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
    static constexpr regex_constants::syntax_option_type multiline = regex_constants::multiline;

    // construct/copy/destroy:
    basic_regex();
    explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
    basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
    basic_regex(const basic_regex&);
    basic_regex(basic_regex&&) noexcept;
    template <class ST, class SA>
        explicit basic_regex(const basic_string<charT, ST, SA>& p,
                             flag_type f = regex_constants::ECMAScript);
    template <class ForwardIterator>
        basic_regex(ForwardIterator first, ForwardIterator last,
                    flag_type f = regex_constants::ECMAScript);
    basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript);

    ~basic_regex();

    basic_regex& operator=(const basic_regex&);
    basic_regex& operator=(basic_regex&&) noexcept;
    basic_regex& operator=(const charT* ptr);
    basic_regex& operator=(initializer_list<charT> il);
    template <class ST, class SA>
        basic_regex& operator=(const basic_string<charT, ST, SA>& p);

    // assign:
    basic_regex& assign(const basic_regex& that);
    basic_regex& assign(basic_regex&& that) noexcept;
    basic_regex& assign(const charT* ptr,           flag_type f = regex_constants::ECMAScript);
    basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
    template <class string_traits, class A>
        basic_regex& assign(const basic_string<charT, string_traits, A>& s,
                                                    flag_type f = regex_constants::ECMAScript);
    template <class InputIterator>
        basic_regex& assign(InputIterator first, InputIterator last,
                                                    flag_type f = regex_constants::ECMAScript);
    basic_regex& assign(initializer_list<charT>,    flag_type f = regex_constants::ECMAScript);

    // const operations:
    unsigned mark_count() const;
    flag_type flags() const;

    // locale:
    locale_type imbue(locale_type loc);
    locale_type getloc() const;

    // swap:
    void swap(basic_regex&);
};

template<class ForwardIterator>
basic_regex(ForwardIterator, ForwardIterator,
            regex_constants::syntax_option_type = regex_constants::ECMAScript)
    -> basic_regex<typename iterator_traits<ForwardIterator>::value_type>; // C++17

typedef basic_regex<char>    regex;
typedef basic_regex<wchar_t> wregex;

template <class charT, class traits>
    void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2);

template <class BidirectionalIterator>
class sub_match
    : public pair<BidirectionalIterator, BidirectionalIterator>
{
public:
    typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;
    typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
    typedef BidirectionalIterator                                      iterator;
    typedef basic_string<value_type>                                string_type;

    bool matched;

    constexpr sub_match();

    difference_type length() const;
    operator string_type() const;
    string_type str() const;

    int compare(const sub_match& s) const;
    int compare(const string_type& s) const;
    int compare(const value_type* s) const;

    void swap(sub_match& s) noexcept(see below);
};

typedef sub_match<const char*>             csub_match;
typedef sub_match<const wchar_t*>          wcsub_match;
typedef sub_match<string::const_iterator>  ssub_match;
typedef sub_match<wstring::const_iterator> wssub_match;

template <class BiIter>
    bool
    operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);

template <class BiIter>
    auto
    operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); // Since C++20

 template <class BiIter>                                                     // Removed in C++20
    bool
    operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
              const sub_match<BiIter>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
              const sub_match<BiIter>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
                    const sub_match<BiIter>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter, class ST, class SA>
    bool
    operator==(const sub_match<BiIter>& lhs,
               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);

template <class BiIter, class ST, class SA>                                  // Since C++20
    auto
    operator<=>(const sub_match<BiIter>& lhs,
                const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator!=(const sub_match<BiIter>& lhs,
               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator<(const sub_match<BiIter>& lhs,
              const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator>(const sub_match<BiIter>& lhs,
                   const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator>=(const sub_match<BiIter>& lhs,
               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator<=(const sub_match<BiIter>& lhs,
               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator==(typename iterator_traits<BiIter>::value_type const* lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<(typename iterator_traits<BiIter>::value_type const* lhs,
              const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>(typename iterator_traits<BiIter>::value_type const* lhs,
              const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter>
    bool
    operator==(const sub_match<BiIter>& lhs,
               typename iterator_traits<BiIter>::value_type const* rhs);

template <class BiIter>                                                      // Since C++20
    auto
    operator<=>(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const* rhs);

template <class BiIter, class ST, class SA>                                  // Removed in C++20
    bool
    operator!=(const sub_match<BiIter>& lhs,
               typename iterator_traits<BiIter>::value_type const* rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<(const sub_match<BiIter>& lhs,
              typename iterator_traits<BiIter>::value_type const* rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>(const sub_match<BiIter>& lhs,
              typename iterator_traits<BiIter>::value_type const* rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>=(const sub_match<BiIter>& lhs,
               typename iterator_traits<BiIter>::value_type const* rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<=(const sub_match<BiIter>& lhs,
               typename iterator_traits<BiIter>::value_type const* rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator==(typename iterator_traits<BiIter>::value_type const& lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<(typename iterator_traits<BiIter>::value_type const& lhs,
              const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>(typename iterator_traits<BiIter>::value_type const& lhs,
              const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
               const sub_match<BiIter>& rhs);

template <class BiIter>
    bool
    operator==(const sub_match<BiIter>& lhs,
               typename iterator_traits<BiIter>::value_type const& rhs);

template <class BiIter>                                                      // Since C++20
    auto
    operator<=>(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator!=(const sub_match<BiIter>& lhs,
               typename iterator_traits<BiIter>::value_type const& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<(const sub_match<BiIter>& lhs,
              typename iterator_traits<BiIter>::value_type const& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>(const sub_match<BiIter>& lhs,
              typename iterator_traits<BiIter>::value_type const& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator>=(const sub_match<BiIter>& lhs,
               typename iterator_traits<BiIter>::value_type const& rhs);

template <class BiIter>                                                      // Removed in C++20
    bool
    operator<=(const sub_match<BiIter>& lhs,
               typename iterator_traits<BiIter>::value_type const& rhs);

template <class charT, class ST, class BiIter>
    basic_ostream<charT, ST>&
    operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);

template <class BidirectionalIterator,
          class Allocator = allocator<sub_match<BidirectionalIterator>>>
class match_results
{
public:
    typedef sub_match<BidirectionalIterator>                  value_type;
    typedef const value_type&                                 const_reference;
    typedef value_type&                                       reference;
    typedef /implementation-defined/                          const_iterator;
    typedef const_iterator                                    iterator;
    typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
    typedef typename allocator_traits<Allocator>::size_type   size_type;
    typedef Allocator                                         allocator_type;
    typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
    typedef basic_string<char_type>                           string_type;

    // construct/copy/destroy:
    explicit match_results(const Allocator& a = Allocator()); // before C++20
    match_results() : match_results(Allocator()) {}           // C++20
    explicit match_results(const Allocator& a);               // C++20
    match_results(const match_results& m);
    match_results(match_results&& m) noexcept;
    match_results& operator=(const match_results& m);
    match_results& operator=(match_results&& m);
    ~match_results();

    bool ready() const;

    // size:
    size_type size() const;
    size_type max_size() const;
    bool empty() const;

    // element access:
    difference_type length(size_type sub = 0) const;
    difference_type position(size_type sub = 0) const;
    string_type str(size_type sub = 0) const;
    const_reference operator[](size_type n) const;

    const_reference prefix() const;
    const_reference suffix() const;

    const_iterator begin() const;
    const_iterator end() const;
    const_iterator cbegin() const;
    const_iterator cend() const;

    // format:
    template <class OutputIter>
        OutputIter
        format(OutputIter out, const char_type* fmt_first,
               const char_type* fmt_last,
               regex_constants::match_flag_type flags = regex_constants::format_default) const;
    template <class OutputIter, class ST, class SA>
        OutputIter
        format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
               regex_constants::match_flag_type flags = regex_constants::format_default) const;
    template <class ST, class SA>
        basic_string<char_type, ST, SA>
        format(const basic_string<char_type, ST, SA>& fmt,
               regex_constants::match_flag_type flags = regex_constants::format_default) const;
    string_type
        format(const char_type* fmt,
               regex_constants::match_flag_type flags = regex_constants::format_default) const;

    // allocator:
    allocator_type get_allocator() const;

    // swap:
    void swap(match_results& that);
};

typedef match_results<const char*>             cmatch;
typedef match_results<const wchar_t*>          wcmatch;
typedef match_results<string::const_iterator>  smatch;
typedef match_results<wstring::const_iterator> wsmatch;

template <class BidirectionalIterator, class Allocator>
    bool
    operator==(const match_results<BidirectionalIterator, Allocator>& m1,
               const match_results<BidirectionalIterator, Allocator>& m2);

template <class BidirectionalIterator, class Allocator>                    // Removed in C++20
    bool
    operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
               const match_results<BidirectionalIterator, Allocator>& m2);

template <class BidirectionalIterator, class Allocator>
    void
    swap(match_results<BidirectionalIterator, Allocator>& m1,
         match_results<BidirectionalIterator, Allocator>& m2);

template <class BidirectionalIterator, class Allocator, class charT, class traits>
    bool
    regex_match(BidirectionalIterator first, BidirectionalIterator last,
                match_results<BidirectionalIterator, Allocator>& m,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags = regex_constants::match_default);

template <class BidirectionalIterator, class charT, class traits>
    bool
    regex_match(BidirectionalIterator first, BidirectionalIterator last,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags = regex_constants::match_default);

template <class charT, class Allocator, class traits>
    bool
    regex_match(const charT* str, match_results<const charT*, Allocator>& m,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags = regex_constants::match_default);

template <class ST, class SA, class Allocator, class charT, class traits>
    bool
    regex_match(const basic_string<charT, ST, SA>& s,
                match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags = regex_constants::match_default);

template <class ST, class SA, class Allocator, class charT, class traits>
    bool
    regex_match(const basic_string<charT, ST, SA>&& s,
                match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14

template <class charT, class traits>
    bool
    regex_match(const charT* str, const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags = regex_constants::match_default);

template <class ST, class SA, class charT, class traits>
    bool
    regex_match(const basic_string<charT, ST, SA>& s,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags = regex_constants::match_default);

template <class BidirectionalIterator, class Allocator, class charT, class traits>
    bool
    regex_search(BidirectionalIterator first, BidirectionalIterator last,
                 match_results<BidirectionalIterator, Allocator>& m,
                 const basic_regex<charT, traits>& e,
                 regex_constants::match_flag_type flags = regex_constants::match_default);

template <class BidirectionalIterator, class charT, class traits>
    bool
    regex_search(BidirectionalIterator first, BidirectionalIterator last,
                 const basic_regex<charT, traits>& e,
                 regex_constants::match_flag_type flags = regex_constants::match_default);

template <class charT, class Allocator, class traits>
    bool
    regex_search(const charT* str, match_results<const charT*, Allocator>& m,
                 const basic_regex<charT, traits>& e,
                 regex_constants::match_flag_type flags = regex_constants::match_default);

template <class charT, class traits>
    bool
    regex_search(const charT* str, const basic_regex<charT, traits>& e,
                 regex_constants::match_flag_type flags = regex_constants::match_default);

template <class ST, class SA, class charT, class traits>
    bool
    regex_search(const basic_string<charT, ST, SA>& s,
                 const basic_regex<charT, traits>& e,
                 regex_constants::match_flag_type flags = regex_constants::match_default);

template <class ST, class SA, class Allocator, class charT, class traits>
    bool
    regex_search(const basic_string<charT, ST, SA>& s,
                 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
                 const basic_regex<charT, traits>& e,
                 regex_constants::match_flag_type flags = regex_constants::match_default);

template <class ST, class SA, class Allocator, class charT, class traits>
    bool
    regex_search(const basic_string<charT, ST, SA>&& s,
                 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
                 const basic_regex<charT, traits>& e,
                 regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14

template <class OutputIterator, class BidirectionalIterator,
          class traits, class charT, class ST, class SA>
    OutputIterator
    regex_replace(OutputIterator out,
                  BidirectionalIterator first, BidirectionalIterator last,
                  const basic_regex<charT, traits>& e,
                  const basic_string<charT, ST, SA>& fmt,
                  regex_constants::match_flag_type flags = regex_constants::match_default);

template <class OutputIterator, class BidirectionalIterator,
          class traits, class charT>
    OutputIterator
    regex_replace(OutputIterator out,
                  BidirectionalIterator first, BidirectionalIterator last,
                  const basic_regex<charT, traits>& e, const charT* fmt,
                  regex_constants::match_flag_type flags = regex_constants::match_default);

template <class traits, class charT, class ST, class SA, class FST, class FSA>
    basic_string<charT, ST, SA>
    regex_replace(const basic_string<charT, ST, SA>& s,
                  const basic_regex<charT, traits>& e,
                  const basic_string<charT, FST, FSA>& fmt,
                  regex_constants::match_flag_type flags = regex_constants::match_default);

template <class traits, class charT, class ST, class SA>
    basic_string<charT, ST, SA>
    regex_replace(const basic_string<charT, ST, SA>& s,
                  const basic_regex<charT, traits>& e, const charT* fmt,
                  regex_constants::match_flag_type flags = regex_constants::match_default);

template <class traits, class charT, class ST, class SA>
    basic_string<charT>
    regex_replace(const charT* s,
                  const basic_regex<charT, traits>& e,
                  const basic_string<charT, ST, SA>& fmt,
                  regex_constants::match_flag_type flags = regex_constants::match_default);

template <class traits, class charT>
    basic_string<charT>
    regex_replace(const charT* s,
                  const basic_regex<charT, traits>& e,
                  const charT* fmt,
                  regex_constants::match_flag_type flags = regex_constants::match_default);

template <class BidirectionalIterator,
          class charT = typename iterator_traits< BidirectionalIterator>::value_type,
          class traits = regex_traits<charT>>
class regex_iterator
{
public:
    typedef basic_regex<charT, traits>           regex_type;
    typedef match_results<BidirectionalIterator> value_type;
    typedef ptrdiff_t                            difference_type;
    typedef const value_type*                    pointer;
    typedef const value_type&                    reference;
    typedef forward_iterator_tag                 iterator_category;
    typedef input_iterator_tag                   iterator_concept; // since C++20

    regex_iterator();
    regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
                   const regex_type& re,
                   regex_constants::match_flag_type m = regex_constants::match_default);
    regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
                   const regex_type&& re,
                   regex_constants::match_flag_type m
                                     = regex_constants::match_default) = delete; // C++14
    regex_iterator(const regex_iterator&);
    regex_iterator& operator=(const regex_iterator&);

    bool operator==(const regex_iterator&) const;
    bool operator==(default_sentinel_t) const { return *this == regex_iterator(); } // since C++20
    bool operator!=(const regex_iterator&) const;                                   // Removed in C++20

    const value_type& operator*() const;
    const value_type* operator->() const;

    regex_iterator& operator++();
    regex_iterator operator++(int);
};

typedef regex_iterator<const char*>             cregex_iterator;
typedef regex_iterator<const wchar_t*>          wcregex_iterator;
typedef regex_iterator<string::const_iterator>  sregex_iterator;
typedef regex_iterator<wstring::const_iterator> wsregex_iterator;

template <class BidirectionalIterator,
          class charT = typename iterator_traits<BidirectionalIterator>::value_type,
          class traits = regex_traits<charT>>
class regex_token_iterator
{
public:
    typedef basic_regex<charT, traits>       regex_type;
    typedef sub_match<BidirectionalIterator> value_type;
    typedef ptrdiff_t                        difference_type;
    typedef const value_type*                pointer;
    typedef const value_type&                reference;
    typedef forward_iterator_tag             iterator_category;
    typedef input_iterator_tag               iterator_concept; // since C++20

    regex_token_iterator();
    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                         const regex_type& re, int submatch = 0,
                         regex_constants::match_flag_type m = regex_constants::match_default);
    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                         const regex_type&& re, int submatch = 0,
                         regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                         const regex_type& re, const vector<int>& submatches,
                         regex_constants::match_flag_type m = regex_constants::match_default);
    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                         const regex_type&& re, const vector<int>& submatches,
                         regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                         const regex_type& re, initializer_list<int> submatches,
                         regex_constants::match_flag_type m = regex_constants::match_default);
    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                         const regex_type&& re, initializer_list<int> submatches,
                         regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
    template <size_t N>
        regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                             const regex_type& re, const int (&submatches)[N],
                             regex_constants::match_flag_type m = regex_constants::match_default);
    template <size_t N>
        regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                             const regex_type&& re, const int (&submatches)[N],
                             regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
    regex_token_iterator(const regex_token_iterator&);
    regex_token_iterator& operator=(const regex_token_iterator&);

    bool operator==(const regex_token_iterator&) const;
    bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); } // since C++20
    bool operator!=(const regex_token_iterator&) const;                                   // Removed in C++20

    const value_type& operator*() const;
    const value_type* operator->() const;

    regex_token_iterator& operator++();
    regex_token_iterator operator++(int);
};

typedef regex_token_iterator<const char*>             cregex_token_iterator;
typedef regex_token_iterator<const wchar_t*>          wcregex_token_iterator;
typedef regex_token_iterator<string::const_iterator>  sregex_token_iterator;
typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;

} // std
*/

#include <__algorithm/find.h>
#include <__algorithm/search.h>
#include <__assert>
#include <__config>
#include <__iterator/back_insert_iterator.h>
#include <__iterator/default_sentinel.h>
#include <__iterator/wrap_iter.h>
#include <__locale>
#include <__memory/shared_ptr.h>
#include <__memory_resource/polymorphic_allocator.h>
#include <__type_traits/is_swappable.h>
#include <__utility/move.h>
#include <__utility/pair.h>
#include <__utility/swap.h>
#include <__verbose_abort>
#include <deque>
#include <stdexcept>
#include <string>
#include <vector>
#include <version>

// standard-mandated includes

// [iterator.range]
#include <__iterator/access.h>
#include <__iterator/data.h>
#include <__iterator/empty.h>
#include <__iterator/reverse_access.h>
#include <__iterator/size.h>

// [re.syn]
#include <compare>
#include <initializer_list>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#  pragma GCC system_header
#endif

_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#define _LIBCPP_REGEX_COMPLEXITY_FACTOR

_LIBCPP_BEGIN_NAMESPACE_STD

namespace regex_constants {

// syntax_option_type

enum syntax_option_type {};

_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR syntax_option_type __get_grammar(syntax_option_type __g) {}

inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type operator~(syntax_option_type __x) {}

inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type
operator&(syntax_option_type __x, syntax_option_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type
operator|(syntax_option_type __x, syntax_option_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type
operator^(syntax_option_type __x, syntax_option_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI syntax_option_type& operator&=(syntax_option_type& __x, syntax_option_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI syntax_option_type& operator|=(syntax_option_type& __x, syntax_option_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI syntax_option_type& operator^=(syntax_option_type& __x, syntax_option_type __y) {}

// match_flag_type

enum match_flag_type {};

inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR match_flag_type operator~(match_flag_type __x) {}

inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR match_flag_type operator&(match_flag_type __x, match_flag_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR match_flag_type operator|(match_flag_type __x, match_flag_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR match_flag_type operator^(match_flag_type __x, match_flag_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI match_flag_type& operator&=(match_flag_type& __x, match_flag_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI match_flag_type& operator|=(match_flag_type& __x, match_flag_type __y) {}

inline _LIBCPP_HIDE_FROM_ABI match_flag_type& operator^=(match_flag_type& __x, match_flag_type __y) {}

enum error_type {};

} // namespace regex_constants

class _LIBCPP_EXPORTED_FROM_ABI regex_error : public runtime_error {};

template <regex_constants::error_type _Ev>
_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() {}

template <class _CharT>
struct _LIBCPP_TEMPLATE_VIS regex_traits {};

template <class _CharT>
const typename regex_traits<_CharT>::char_class_type regex_traits<_CharT>::__regex_word;

template <class _CharT>
regex_traits<_CharT>::regex_traits() {}

template <class _CharT>
typename regex_traits<_CharT>::char_type regex_traits<_CharT>::translate_nocase(char_type __c) const {}

template <class _CharT>
template <class _ForwardIterator>
typename regex_traits<_CharT>::string_type
regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const {}

template <class _CharT>
void regex_traits<_CharT>::__init() {}

template <class _CharT>
typename regex_traits<_CharT>::locale_type regex_traits<_CharT>::imbue(locale_type __l) {}

// transform_primary is very FreeBSD-specific

template <class _CharT>
template <class _ForwardIterator>
typename regex_traits<_CharT>::string_type
regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const {}

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class _CharT>
template <class _ForwardIterator>
typename regex_traits<_CharT>::string_type
regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const {}
#endif

// lookup_collatename is very FreeBSD-specific

_LIBCPP_EXPORTED_FROM_ABI string __get_collation_name(const char* __s);

template <class _CharT>
template <class _ForwardIterator>
typename regex_traits<_CharT>::string_type
regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const {}

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class _CharT>
template <class _ForwardIterator>
typename regex_traits<_CharT>::string_type
regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const {}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS

// lookup_classname

regex_traits<char>::char_class_type _LIBCPP_EXPORTED_FROM_ABI __get_classname(const char* __s, bool __icase);

template <class _CharT>
template <class _ForwardIterator>
typename regex_traits<_CharT>::char_class_type
regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const {}

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class _CharT>
template <class _ForwardIterator>
typename regex_traits<_CharT>::char_class_type
regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const {}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS

template <class _CharT>
bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const {}

inline _LIBCPP_HIDE_FROM_ABI bool __is_07(unsigned char __c) {}

inline _LIBCPP_HIDE_FROM_ABI bool __is_89(unsigned char __c) {}

inline _LIBCPP_HIDE_FROM_ABI unsigned char __to_lower(unsigned char __c) {}

template <class _CharT>
int regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) {}

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class _CharT>
inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const {}
#endif

template <class _CharT>
class __node;

template <class _BidirectionalIterator>
class _LIBCPP_TEMPLATE_VIS sub_match;

template <class _BidirectionalIterator, class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
class _LIBCPP_TEMPLATE_VIS match_results;

template <class _CharT>
struct __state {};

// __node

template <class _CharT>
class __node {};

// __end_state

template <class _CharT>
class __end_state : public __node<_CharT> {};

template <class _CharT>
void __end_state<_CharT>::__exec(__state& __s) const {}

// __has_one_state

template <class _CharT>
class __has_one_state : public __node<_CharT> {};

// __owns_one_state

template <class _CharT>
class __owns_one_state : public __has_one_state<_CharT> {};

template <class _CharT>
__owns_one_state<_CharT>::~__owns_one_state() {}

// __empty_state

template <class _CharT>
class __empty_state : public __owns_one_state<_CharT> {};

template <class _CharT>
void __empty_state<_CharT>::__exec(__state& __s) const {}

// __empty_non_own_state

template <class _CharT>
class __empty_non_own_state : public __has_one_state<_CharT> {};

template <class _CharT>
void __empty_non_own_state<_CharT>::__exec(__state& __s) const {}

// __repeat_one_loop

template <class _CharT>
class __repeat_one_loop : public __has_one_state<_CharT> {};

template <class _CharT>
void __repeat_one_loop<_CharT>::__exec(__state& __s) const {}

// __owns_two_states

template <class _CharT>
class __owns_two_states : public __owns_one_state<_CharT> {};

template <class _CharT>
__owns_two_states<_CharT>::~__owns_two_states() {}

// __loop

template <class _CharT>
class __loop : public __owns_two_states<_CharT> {};

template <class _CharT>
void __loop<_CharT>::__exec(__state& __s) const {}

template <class _CharT>
void __loop<_CharT>::__exec_split(bool __second, __state& __s) const {}

// __alternate

template <class _CharT>
class __alternate : public __owns_two_states<_CharT> {};

template <class _CharT>
void __alternate<_CharT>::__exec(__state& __s) const {}

template <class _CharT>
void __alternate<_CharT>::__exec_split(bool __second, __state& __s) const {}

// __begin_marked_subexpression

template <class _CharT>
class __begin_marked_subexpression : public __owns_one_state<_CharT> {};

template <class _CharT>
void __begin_marked_subexpression<_CharT>::__exec(__state& __s) const {}

// __end_marked_subexpression

template <class _CharT>
class __end_marked_subexpression : public __owns_one_state<_CharT> {};

template <class _CharT>
void __end_marked_subexpression<_CharT>::__exec(__state& __s) const {}

// __back_ref

template <class _CharT>
class __back_ref : public __owns_one_state<_CharT> {};

template <class _CharT>
void __back_ref<_CharT>::__exec(__state& __s) const {}

// __back_ref_icase

template <class _CharT, class _Traits>
class __back_ref_icase : public __owns_one_state<_CharT> {};

template <class _CharT, class _Traits>
void __back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const {}

// __back_ref_collate

template <class _CharT, class _Traits>
class __back_ref_collate : public __owns_one_state<_CharT> {};

template <class _CharT, class _Traits>
void __back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const {}

// __word_boundary

template <class _CharT, class _Traits>
class __word_boundary : public __owns_one_state<_CharT> {};

template <class _CharT, class _Traits>
void __word_boundary<_CharT, _Traits>::__exec(__state& __s) const {}

// __l_anchor

template <class _CharT>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __is_eol(_CharT __c) {}

template <class _CharT>
class __l_anchor_multiline : public __owns_one_state<_CharT> {};

template <class _CharT>
void __l_anchor_multiline<_CharT>::__exec(__state& __s) const {}

// __r_anchor

template <class _CharT>
class __r_anchor_multiline : public __owns_one_state<_CharT> {};

template <class _CharT>
void __r_anchor_multiline<_CharT>::__exec(__state& __s) const {}

// __match_any

template <class _CharT>
class __match_any : public __owns_one_state<_CharT> {};

template <class _CharT>
void __match_any<_CharT>::__exec(__state& __s) const {}

// __match_any_but_newline

template <class _CharT>
class __match_any_but_newline : public __owns_one_state<_CharT> {};

template <>
_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<char>::__exec(__state&) const;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<wchar_t>::__exec(__state&) const;
#endif

// __match_char

template <class _CharT>
class __match_char : public __owns_one_state<_CharT> {};

template <class _CharT>
void __match_char<_CharT>::__exec(__state& __s) const {}

// __match_char_icase

template <class _CharT, class _Traits>
class __match_char_icase : public __owns_one_state<_CharT> {};

template <class _CharT, class _Traits>
void __match_char_icase<_CharT, _Traits>::__exec(__state& __s) const {}

// __match_char_collate

template <class _CharT, class _Traits>
class __match_char_collate : public __owns_one_state<_CharT> {};

template <class _CharT, class _Traits>
void __match_char_collate<_CharT, _Traits>::__exec(__state& __s) const {}

// __bracket_expression

template <class _CharT, class _Traits>
class __bracket_expression : public __owns_one_state<_CharT> {};

template <class _CharT, class _Traits>
void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {}

template <class _CharT, class _Traits>
class __lookahead;

template <class _CharT, class _Traits = regex_traits<_CharT> >
class _LIBCPP_TEMPLATE_VIS basic_regex;

regex;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
wregex;
#endif

template <class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(regex)
    _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wregex)) basic_regex {};

#if _LIBCPP_STD_VER >= 17
template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript)
    -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;
#endif

template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::nosubs;
template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::optimize;
template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::collate;
template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::ECMAScript;
template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::basic;
template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::extended;
template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::awk;
template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::grep;
template <class _CharT, class _Traits>
const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::egrep;

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::swap(basic_regex& __r) {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI void swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y) {}

// __lookahead

template <class _CharT, class _Traits>
class __lookahead : public __owns_one_state<_CharT> {};

template <class _CharT, class _Traits>
void __lookahead<_CharT, _Traits>::__exec(__state& __s) const {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
void basic_regex<_CharT, _Traits>::__init(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(
    _ForwardIterator __first,
    _ForwardIterator __last,
    __owns_one_state<_CharT>* __s,
    unsigned __mexp_begin,
    unsigned __mexp_end) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(
    _ForwardIterator __first,
    _ForwardIterator __last,
    __owns_one_state<_CharT>* __s,
    unsigned __mexp_begin,
    unsigned __mexp_end) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_follow_list(
    _ForwardIterator __first, _ForwardIterator __last, __bracket_expression<_CharT, _Traits>* __ml) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_expression_term(
    _ForwardIterator __first, _ForwardIterator __last, __bracket_expression<_CharT, _Traits>* __ml) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_class_escape(
    _ForwardIterator __first,
    _ForwardIterator __last,
    basic_string<_CharT>& __str,
    __bracket_expression<_CharT, _Traits>* __ml) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_awk_escape(
    _ForwardIterator __first, _ForwardIterator __last, basic_string<_CharT>* __str) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_equivalence_class(
    _ForwardIterator __first, _ForwardIterator __last, __bracket_expression<_CharT, _Traits>* __ml) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_class(
    _ForwardIterator __first, _ForwardIterator __last, __bracket_expression<_CharT, _Traits>* __ml) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_collating_symbol(
    _ForwardIterator __first, _ForwardIterator __last, basic_string<_CharT>& __col_sym) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(
    _ForwardIterator __first, _ForwardIterator __last, basic_string<_CharT>* __str) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator
basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
template <class _ForwardIterator>
_ForwardIterator basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first, _ForwardIterator __last) {}

template <class _CharT, class _Traits>
bool basic_regex<_CharT, _Traits>::__test_back_ref(_CharT __c) {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_loop(
    size_t __min, size_t __max, __owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end, bool __greedy) {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_char(value_type __c) {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression() {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub) {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_l_anchor() {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_r_anchor() {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_match_any() {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_match_any_but_newline() {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_empty() {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert) {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_back_ref(int __i) {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa, __owns_one_state<_CharT>* __ea) {}

template <class _CharT, class _Traits>
__bracket_expression<_CharT, _Traits>* basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate) {}

template <class _CharT, class _Traits>
void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, bool __invert, unsigned __mexp) {}

// sub_match

csub_match;
ssub_match;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
wcsub_match;
wssub_match;
#endif

template <class _BidirectionalIterator>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(csub_match)
    _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcsub_match)) _LIBCPP_PREFERRED_NAME(ssub_match)
        _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wssub_match)) sub_match
    : public pair<_BidirectionalIterator, _BidirectionalIterator> {};

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {}

#if _LIBCPP_STD_VER >= 20
__sub_match_cat;

template <class _BiIter>
_LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {}
#else  // _LIBCPP_STD_VER >= 20
template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {
  return !(__x == __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {
  return __x.compare(__y) < 0;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {
  return !(__y < __x);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {
  return !(__x < __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {
  return __y < __x;
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
           const sub_match<_BiIter>& __y) {
  return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
           const sub_match<_BiIter>& __y) {
  return !(__x == __y);
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
          const sub_match<_BiIter>& __y) {
  return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
          const sub_match<_BiIter>& __y) {
  return __y < __x;
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
           const sub_match<_BiIter>& __y) {
  return !(__x < __y);
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
           const sub_match<_BiIter>& __y) {
  return !(__y < __x);
}
#endif // _LIBCPP_STD_VER >= 20

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator==(const sub_match<_BiIter>& __x,
           const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) {}

#if _LIBCPP_STD_VER >= 20
template <class _BiIter, class _ST, class _SA>
_LIBCPP_HIDE_FROM_ABI auto
operator<=>(const sub_match<_BiIter>& __x,
            const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) {}
#else  // _LIBCPP_STD_VER >= 20
template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator!=(const sub_match<_BiIter>& __x,
           const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) {
  return !(__x == __y);
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<(const sub_match<_BiIter>& __x,
          const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) {
  return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>(const sub_match<_BiIter>& __x,
          const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) {
  return __y < __x;
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>=(const sub_match<_BiIter>& __x,
           const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) {
  return !(__x < __y);
}

template <class _BiIter, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<=(const sub_match<_BiIter>& __x,
           const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) {
  return !(__y < __x);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator==(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {
  return __y.compare(__x) == 0;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator!=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {
  return !(__x == __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {
  return __y.compare(__x) > 0;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {
  return __y < __x;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {
  return !(__x < __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {
  return !(__y < __x);
}
#endif // _LIBCPP_STD_VER >= 20

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {}

#if _LIBCPP_STD_VER >= 20
template <class _BiIter>
_LIBCPP_HIDE_FROM_ABI auto
operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {}
#else  // _LIBCPP_STD_VER >= 20
template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {
  return !(__x == __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {
  return __x.compare(__y) < 0;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {
  return __y < __x;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {
  return !(__x < __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {
  return !(__y < __x);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator==(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {
  typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
  return __y.compare(string_type(1, __x)) == 0;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator!=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {
  return !(__x == __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {
  typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
  return __y.compare(string_type(1, __x)) > 0;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {
  return __y < __x;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {
  return !(__x < __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {
  return !(__y < __x);
}
#endif // _LIBCPP_STD_VER >= 20

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {}

#if _LIBCPP_STD_VER >= 20
template <class _BiIter>
_LIBCPP_HIDE_FROM_ABI auto
operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {}
#else  // _LIBCPP_STD_VER >= 20
template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
  return !(__x == __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
  typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
  return __x.compare(string_type(1, __y)) < 0;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
  return __y < __x;
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator>=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
  return !(__x < __y);
}

template <class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI bool
operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
  return !(__y < __x);
}
#endif // _LIBCPP_STD_VER >= 20

template <class _CharT, class _ST, class _BiIter>
inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _ST>&
operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) {}

cmatch;
smatch;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
wcmatch;
wsmatch;
#endif

template <class _BidirectionalIterator, class _Allocator>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cmatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch))
    _LIBCPP_PREFERRED_NAME(smatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsmatch)) match_results {};

template <class _BidirectionalIterator, class _Allocator>
match_results<_BidirectionalIterator, _Allocator>::match_results(const allocator_type& __a)
    :{}

template <class _BidirectionalIterator, class _Allocator>
void match_results<_BidirectionalIterator, _Allocator>::__init(
    unsigned __s, _BidirectionalIterator __f, _BidirectionalIterator __l, bool __no_update_pos) {}

template <class _BidirectionalIterator, class _Allocator>
template <class _OutputIter>
_OutputIter match_results<_BidirectionalIterator, _Allocator>::format(
    _OutputIter __output_iter,
    const char_type* __fmt_first,
    const char_type* __fmt_last,
    regex_constants::match_flag_type __flags) const {}

template <class _BidirectionalIterator, class _Allocator>
void match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m) {}

template <class _BidirectionalIterator, class _Allocator>
_LIBCPP_HIDE_FROM_ABI bool operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
                                      const match_results<_BidirectionalIterator, _Allocator>& __y) {}

#if _LIBCPP_STD_VER < 20
template <class _BidirectionalIterator, class _Allocator>
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
                                             const match_results<_BidirectionalIterator, _Allocator>& __y) {
  return !(__x == __y);
}
#endif

template <class _BidirectionalIterator, class _Allocator>
inline _LIBCPP_HIDE_FROM_ABI void
swap(match_results<_BidirectionalIterator, _Allocator>& __x, match_results<_BidirectionalIterator, _Allocator>& __y) {}

// regex_search

template <class _CharT, class _Traits>
template <class _Allocator>
bool basic_regex<_CharT, _Traits>::__match_at_start_ecma(
    const _CharT* __first,
    const _CharT* __last,
    match_results<const _CharT*, _Allocator>& __m,
    regex_constants::match_flag_type __flags,
    bool __at_first) const {}

template <class _CharT, class _Traits>
template <class _Allocator>
bool basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
    const _CharT* __first,
    const _CharT* __last,
    match_results<const _CharT*, _Allocator>& __m,
    regex_constants::match_flag_type __flags,
    bool __at_first) const {}

template <class _CharT, class _Traits>
template <class _Allocator>
bool basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
    const _CharT* __first,
    const _CharT* __last,
    match_results<const _CharT*, _Allocator>& __m,
    regex_constants::match_flag_type __flags,
    bool __at_first) const {}

template <class _CharT, class _Traits>
template <class _Allocator>
bool basic_regex<_CharT, _Traits>::__match_at_start(
    const _CharT* __first,
    const _CharT* __last,
    match_results<const _CharT*, _Allocator>& __m,
    regex_constants::match_flag_type __flags,
    bool __at_first) const {}

template <class _CharT, class _Traits>
template <class _Allocator>
bool basic_regex<_CharT, _Traits>::__search(
    const _CharT* __first,
    const _CharT* __last,
    match_results<const _CharT*, _Allocator>& __m,
    regex_constants::match_flag_type __flags) const {}

template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_search(_BidirectionalIterator __first,
             _BidirectionalIterator __last,
             match_results<_BidirectionalIterator, _Allocator>& __m,
             const basic_regex<_CharT, _Traits>& __e,
             regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _Iter, class _Allocator, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_search(__wrap_iter<_Iter> __first,
             __wrap_iter<_Iter> __last,
             match_results<__wrap_iter<_Iter>, _Allocator>& __m,
             const basic_regex<_CharT, _Traits>& __e,
             regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _Allocator, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_search(const _CharT* __first,
             const _CharT* __last,
             match_results<const _CharT*, _Allocator>& __m,
             const basic_regex<_CharT, _Traits>& __e,
             regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _BidirectionalIterator, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_search(_BidirectionalIterator __first,
             _BidirectionalIterator __last,
             const basic_regex<_CharT, _Traits>& __e,
             regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_search(const _CharT* __first,
             const _CharT* __last,
             const basic_regex<_CharT, _Traits>& __e,
             regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _CharT, class _Allocator, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_search(const _CharT* __str,
             match_results<const _CharT*, _Allocator>& __m,
             const basic_regex<_CharT, _Traits>& __e,
             regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_search(const _CharT* __str,
             const basic_regex<_CharT, _Traits>& __e,
             regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _ST, class _SA, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_search(const basic_string<_CharT, _ST, _SA>& __s,
             const basic_regex<_CharT, _Traits>& __e,
             regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_search(const basic_string<_CharT, _ST, _SA>& __s,
             match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
             const basic_regex<_CharT, _Traits>& __e,
             regex_constants::match_flag_type __flags = regex_constants::match_default) {}

#if _LIBCPP_STD_VER >= 14
template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
bool regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
                  match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
                  const basic_regex<_Cp, _Tp>& __e,
                  regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
#endif

// regex_match

template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI bool
regex_match(_BidirectionalIterator __first,
            _BidirectionalIterator __last,
            match_results<_BidirectionalIterator, _Allocator>& __m,
            const basic_regex<_CharT, _Traits>& __e,
            regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _BidirectionalIterator, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_match(_BidirectionalIterator __first,
            _BidirectionalIterator __last,
            const basic_regex<_CharT, _Traits>& __e,
            regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _CharT, class _Allocator, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_match(const _CharT* __str,
            match_results<const _CharT*, _Allocator>& __m,
            const basic_regex<_CharT, _Traits>& __e,
            regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_match(const basic_string<_CharT, _ST, _SA>& __s,
            match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
            const basic_regex<_CharT, _Traits>& __e,
            regex_constants::match_flag_type __flags = regex_constants::match_default) {}

#if _LIBCPP_STD_VER >= 14
template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
            match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
            const basic_regex<_CharT, _Traits>& __e,
            regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
#endif

template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_match(const _CharT* __str,
            const basic_regex<_CharT, _Traits>& __e,
            regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _ST, class _SA, class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI bool
regex_match(const basic_string<_CharT, _ST, _SA>& __s,
            const basic_regex<_CharT, _Traits>& __e,
            regex_constants::match_flag_type __flags = regex_constants::match_default) {}

// regex_iterator

template <class _BidirectionalIterator,
          class _CharT  = typename iterator_traits<_BidirectionalIterator>::value_type,
          class _Traits = regex_traits<_CharT> >
class _LIBCPP_TEMPLATE_VIS regex_iterator;

cregex_iterator;
sregex_iterator;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
wcregex_iterator;
wsregex_iterator;
#endif

template <class _BidirectionalIterator, class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_iterator)
    _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_iterator)) _LIBCPP_PREFERRED_NAME(sregex_iterator)
        _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator)) regex_iterator {};

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator()
    :{}

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator(
    _BidirectionalIterator __a,
    _BidirectionalIterator __b,
    const regex_type& __re,
    regex_constants::match_flag_type __m)
    :{}

template <class _BidirectionalIterator, class _CharT, class _Traits>
bool regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator==(const regex_iterator& __x) const {}

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_iterator<_BidirectionalIterator, _CharT, _Traits>&
regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {}

// regex_token_iterator

template <class _BidirectionalIterator,
          class _CharT  = typename iterator_traits<_BidirectionalIterator>::value_type,
          class _Traits = regex_traits<_CharT> >
class _LIBCPP_TEMPLATE_VIS regex_token_iterator;

cregex_token_iterator;
sregex_token_iterator;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
wcregex_token_iterator;
wsregex_token_iterator;
#endif

template <class _BidirectionalIterator, class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_token_iterator)
    _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_token_iterator))
        _LIBCPP_PREFERRED_NAME(sregex_token_iterator)
            _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_token_iterator)) regex_token_iterator {};

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator()
    :{}

template <class _BidirectionalIterator, class _CharT, class _Traits>
void regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::__init(
    _BidirectionalIterator __a, _BidirectionalIterator __b) {}

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator(
    _BidirectionalIterator __a,
    _BidirectionalIterator __b,
    const regex_type& __re,
    int __submatch,
    regex_constants::match_flag_type __m)
    :{}

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator(
    _BidirectionalIterator __a,
    _BidirectionalIterator __b,
    const regex_type& __re,
    const vector<int>& __submatches,
    regex_constants::match_flag_type __m)
    :{}

#ifndef _LIBCPP_CXX03_LANG

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator(
    _BidirectionalIterator __a,
    _BidirectionalIterator __b,
    const regex_type& __re,
    initializer_list<int> __submatches,
    regex_constants::match_flag_type __m)
    :{}

#endif // _LIBCPP_CXX03_LANG

template <class _BidirectionalIterator, class _CharT, class _Traits>
template <size_t _Np>
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator(
    _BidirectionalIterator __a,
    _BidirectionalIterator __b,
    const regex_type& __re,
    const int (&__submatches)[_Np],
    regex_constants::match_flag_type __m)
    : __position_(__a, __b, __re, __m), __n_(0), __subs_(begin(__submatches), end(__submatches)) {}

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator(const regex_token_iterator& __x)
    :{}

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator=(const regex_token_iterator& __x) {}

template <class _BidirectionalIterator, class _CharT, class _Traits>
bool regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator==(const regex_token_iterator& __x) const {}

template <class _BidirectionalIterator, class _CharT, class _Traits>
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {}

// regex_replace

template <class _OutputIterator, class _BidirectionalIterator, class _Traits, class _CharT>
_LIBCPP_HIDE_FROM_ABI _OutputIterator regex_replace(
    _OutputIterator __output_iter,
    _BidirectionalIterator __first,
    _BidirectionalIterator __last,
    const basic_regex<_CharT, _Traits>& __e,
    const _CharT* __fmt,
    regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _OutputIterator, class _BidirectionalIterator, class _Traits, class _CharT, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI _OutputIterator regex_replace(
    _OutputIterator __output_iter,
    _BidirectionalIterator __first,
    _BidirectionalIterator __last,
    const basic_regex<_CharT, _Traits>& __e,
    const basic_string<_CharT, _ST, _SA>& __fmt,
    regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _Traits, class _CharT, class _ST, class _SA, class _FST, class _FSA>
inline _LIBCPP_HIDE_FROM_ABI basic_string<_CharT, _ST, _SA>
regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
              const basic_regex<_CharT, _Traits>& __e,
              const basic_string<_CharT, _FST, _FSA>& __fmt,
              regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _Traits, class _CharT, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI basic_string<_CharT, _ST, _SA>
regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
              const basic_regex<_CharT, _Traits>& __e,
              const _CharT* __fmt,
              regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _Traits, class _CharT, class _ST, class _SA>
inline _LIBCPP_HIDE_FROM_ABI basic_string<_CharT>
regex_replace(const _CharT* __s,
              const basic_regex<_CharT, _Traits>& __e,
              const basic_string<_CharT, _ST, _SA>& __fmt,
              regex_constants::match_flag_type __flags = regex_constants::match_default) {}

template <class _Traits, class _CharT>
inline _LIBCPP_HIDE_FROM_ABI basic_string<_CharT>
regex_replace(const _CharT* __s,
              const basic_regex<_CharT, _Traits>& __e,
              const _CharT* __fmt,
              regex_constants::match_flag_type __flags = regex_constants::match_default) {}

_LIBCPP_END_NAMESPACE_STD

#if _LIBCPP_STD_VER >= 17
_LIBCPP_BEGIN_NAMESPACE_STD
namespace pmr {
match_results;

cmatch;
smatch;

#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
wcmatch;
wsmatch;
#  endif
} // namespace pmr
_LIBCPP_END_NAMESPACE_STD
#endif

_LIBCPP_POP_MACROS

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
#  include <atomic>
#  include <concepts>
#  include <cstdlib>
#  include <iosfwd>
#  include <iterator>
#  include <mutex>
#  include <new>
#  include <type_traits>
#  include <typeinfo>
#  include <utility>
#endif

#endif // _LIBCPP_REGEX