This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++14 status.
regex_constants
Section: 28.6.4.3 [re.matchflag] Status: C++14 Submitter: BSI Opened: 2010-08-25 Last modified: 2016-01-28
Priority: 3
View all other issues in [re.matchflag].
View all issues with C++14 status.
Discussion:
Addresses GB-127
The Bitmask Type requirements in 16.3.3.3.3 [bitmask.types] p.3 say that
all elements on a bitmask type have distinct values, but
28.6.4.3 [re.matchflag] defines regex_constants::match_default
and
regex_constants::format_default
as elements of the
bitmask type regex_constants::match_flag_type
, both with
value 0. This is a contradiction.
[ Resolution proposed by ballot comment: ]
One of the bitmask elements should be removed from the declaration and should be defined separately, in the same manner as
ios_base::adjustfield
,ios_base::basefield
andios_base::floatfield
are defined by [ios::fmtflags] p.2 and Table 120. These are constants of a bitmask type, but are not distinct elements, they have more than one value set in the bitmask.regex_constants::format_default
should be specified as a constant with the same value asregex_constants::match_default
.
[ 2010-10-31 Daniel comments: ]
Strictly speaking, a bitmask type cannot have any element of value 0 at all, because any such value would contradict the requirement expressed in 16.3.3.3.3 [bitmask.types] p. 3:
for any pair Ci and Cj, Ci & Ci is nonzero
So, actually both regex_constants::match_default
and
regex_constants::format_default
are only constants of the type
regex_constants::match_flag_type
, and no bitmask elements.
[ 2010-11-03 Daniel comments and provides a proposed resolution: ]
The proposed resolution is written against N3126 and considered as a further improvement of the fixes suggested by n3110.
Add the following sentence to 28.6.4.3 [re.matchflag] paragraph 1:
1 The type
regex_constants::match_flag_type
is an implementation-defined bitmask type (17.5.2.1.3). Matching a regular expression against a sequence of characters [first,last) proceeds according to the rules of the grammar specified for the regular expression object, modified according to the effects listed in Table 136 for any bitmask elements set. Typeregex_constants::match_flag_type
also defines the constantsregex_constants::match_default
andregex_constants::format_default
.
[ 2011 Bloomington ]
It appears the key problem is the phrasing of the bitmask requirements. Jeremiah supplies updated wording.
Pete Becker has also provided an alternative resolution.
Ammend 16.3.3.3.3 [bitmask.types]:
Change the list of values for "enum bit mask" in p2 from
V0 = 1 << 0, V1 = 1 << 1, V2 = 1 << 2, V3 = 1 << 3, ...
.
to
V0 = 0, V1 = 1 << 0, V2 = 1 << 1, V3 = 1 << 2, ...
.
Here, the names C0, C1, etc. represent bitmask elements for this particular
bitmask type. All such non-zero elements have distinct values such that, for any pair
Ci and Cj where i != j, Ci & Ci is nonzero
and Ci & Cj is zero.
Change bullet 3 of paragraph 4:
TheA non-zero value Y is set in the object X if the expression X & Y is nonzero.
[2014-02-13 Issaquah:]
Proposed resolution:
Ammend 16.3.3.3.3 [bitmask.types] p3:
Here, the names C0, C1, etc. represent bitmask elements for this particular bitmask type. All such elements have distinct, nonzero values such that, for any pair Ci and Cj where i != j, Ci & Ci is nonzero and Ci & Cj is zero. Additionally, the value 0 is used to represent an empty bitmask, in which no bitmask elements are set.
Add the following sentence to 28.6.4.3 [re.matchflag] paragraph 1:
1 The type
regex_constants::match_flag_type
is an implementation-defined bitmask type (17.5.2.1.3). The constants of that type, except formatch_default
andformat_default
, are bitmask elements. Thematch_default
andformat_default
constants are empty bitmasks. Matching a regular expression against a sequence of characters [first,last) proceeds according to the rules of the grammar specified for the regular expression object, modified according to the effects listed in Table 136 for any bitmask elements set.