[re.regex.general]

# 28 Text processing library [[text]](./#text)

## 28.6 Regular expressions library [[re]](re#regex.general)

### 28.6.7 Class template basic_regex [[re.regex]](re.regex#general)

#### 28.6.7.1 General [re.regex.general]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L10310)

For a char-like type charT, specializations of class
template basic_regex represent regular expressions constructed
from character sequences of charT characters[.](#1.sentence-1)

In the rest
of [[re.regex]](re.regex "28.6.7 Class template basic_­regex"), charT denotes a given char-like
type[.](#1.sentence-2)

Storage for a regular expression is allocated and freed as
necessary by the member functions of class basic_regex[.](#1.sentence-3)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L10318)

Objects of type specialization of basic_regex are responsible for
converting the sequence of charT objects to an internal
representation[.](#2.sentence-1)

It is not specified what form this representation
takes, nor how it is accessed by algorithms that operate on regular
expressions[.](#2.sentence-2)

[*Note [1](#note-1)*:

Implementations will typically declare
some function templates as friends of basic_regex to achieve
this[.](#2.sentence-3)

â *end note*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L10330)

The functions described in [[re.regex]](re.regex "28.6.7 Class template basic_­regex") report errors by throwing
exceptions of type regex_error[.](#3.sentence-1)

[ð](#lib:basic_regex_)

namespace std {template<class charT, class traits = regex_traits<charT>>class basic_regex {public:// typesusing value_type = charT; using traits_type = traits; using string_type = typename traits::string_type; using flag_type = regex_constants::syntax_option_type; using locale_type = typename traits::locale_type; // [[re.synopt]](re.synopt "28.6.4.2 Bitmask type syntax_­option_­type"), constantsstatic constexpr flag_type icase = regex_constants::icase; static constexpr flag_type nosubs = regex_constants::nosubs; static constexpr flag_type optimize = regex_constants::optimize; static constexpr flag_type collate = regex_constants::collate; static constexpr flag_type ECMAScript = regex_constants::ECMAScript; static constexpr flag_type basic = regex_constants::basic; static constexpr flag_type extended = regex_constants::extended; static constexpr flag_type awk = regex_constants::awk; static constexpr flag_type grep = regex_constants::grep; static constexpr flag_type egrep = regex_constants::egrep; static constexpr flag_type multiline = regex_constants::multiline; // [[re.regex.construct]](re.regex.construct "28.6.7.2 Constructors"), 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>& s,
 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> il, flag_type f = regex_constants::ECMAScript); ~basic_regex(); // [[re.regex.assign]](re.regex.assign "28.6.7.3 Assignment"), assign basic_regex& operator=(const basic_regex& e);
 basic_regex& operator=(basic_regex&& e) noexcept;
 basic_regex& operator=(const charT* p);
 basic_regex& operator=(initializer_list<charT> il); template<class ST, class SA> basic_regex& operator=(const basic_string<charT, ST, SA>& s);

 basic_regex& assign(const basic_regex& e);
 basic_regex& assign(basic_regex&& e) noexcept;
 basic_regex& assign(const charT* p, flag_type f = regex_constants::ECMAScript);
 basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript); template<class ST, class SA> basic_regex& assign(const basic_string<charT, ST, SA>& 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); // [[re.regex.operations]](re.regex.operations "28.6.7.4 Constant operations"), const operationsunsigned mark_count() const;
 flag_type flags() const; // [[re.regex.locale]](re.regex.locale "28.6.7.5 Locale"), locale locale_type imbue(locale_type loc);
 locale_type getloc() const; // [[re.regex.swap]](re.regex.swap "28.6.7.6 Swap"), swapvoid 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>;}
