Namespaces
Variants

std::match_results<BidirIt,Alloc>:: match_results

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
match_results ( ) : match_results ( Allocator ( ) ) { }
(1)
explicit match_results ( const Allocator & a ) ;
(2)
match_results ( const match_results & rhs ) ;
(3)
match_results ( const match_results & rhs, const Allocator & a ) ;
(4)
match_results ( match_results && rhs ) noexcept ;
(5)
match_results ( match_results && rhs, const Allocator & a ) ;
(6)
**说明**: 1. 默认构造函数 2. 显式分配器构造函数 3. 拷贝构造函数 4. 带分配器的拷贝构造函数 5. 移动构造函数(noexcept) 6. 带分配器的移动构造函数 注:所有C++代码和术语均按原样保留,仅对构造函数的描述性说明进行了翻译。
1,2) 构造一个未建立结果状态的匹配结果。
1) 默认构造函数。
2) 使用 a 的副本作为分配器来构造匹配结果。
当构造完成时, ready() 返回 false size() 返回 0
3-6) rhs 构造匹配结果。
3) 复制构造函数。
4) 使用 a 的副本作为分配器来构造匹配结果。
5) 移动构造函数。构造完成后, rhs 处于有效但未指定的状态。
6) 使用 a 的副本作为分配器构造匹配结果。构造完成后, rhs 处于有效但未指定的状态。
给定构造前 rhs 的值为 m 且任意整数 [ 0 , m. size ( ) ) n ,当构造完成时,以下成员函数应返回指定值:
成员函数 返回值
ready() m. ready ( )
size() m. size ( )
str(n) m. str ( n )
prefix() m. prefix ( )
suffix() m. suffix ( )
operator[](n) m [ n ]
length(n) m. length ( n )
position(n) m. position ( n )

目录

参数

a - 用于此容器所有内存分配的分配器
rhs - 用作源以初始化 match_results 的另一个 match_results 对象

异常

1-4) 可能抛出由实现定义的异常。
6) a == rhs. get_allocator ( ) true 时不抛出任何异常。

示例

缺陷报告

以下行为变更缺陷报告被追溯应用于先前发布的C++标准。

缺陷报告 适用版本 发布时行为 正确行为
LWG 2191 C++11 重载版本 (3-6) 的后置条件中 n 可能为负值 只能为非负值
LWG 2195 C++11 缺少 AllocatorAwareContainer 要求的构造函数 已添加
P0935R0 C++11 默认构造函数为显式 改为隐式