This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++14 status.
regex_constantsSection: 28.6.4.3[re.matchflag]Status:C++14Submitter: BSIOpened: 2010-08-25Last modified: 2016-01-28
Priority:3
View all otherissues in [re.matchflag].
View all issues withC++14 status.
Discussion:
Addresses GB-127
The Bitmask Type requirements in 16.3.3.3.3[bitmask.types] p.3 say thatall elements on a bitmask type have distinct values, but28.6.4.3[re.matchflag] definesregex_constants::match_default andregex_constants::format_default as elements of thebitmask typeregex_constants::match_flag_type, both withvalue 0. This is a contradiction.
[Resolution proposed by ballot comment:]
One of the bitmask elements should be removedfrom the declaration and should be definedseparately, in the same manner as
ios_base::adjustfield,ios_base::basefieldandios_base::floatfieldare defined by [ios::fmtflags] p.2and Table 120. These are constants of a bitmasktype, but are not distinct elements, they havemore than one value set in the bitmask.regex_constants::format_defaultshould bespecified 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, becauseany such value would contradict the requirement expressed in 16.3.3.3.3[bitmask.types] p. 3:
for any pairCi andCj,Ci &Ci is nonzero
So, actuallybothregex_constants::match_default andregex_constants::format_default are only constants of the typeregex_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 improvementof the fixes suggested byn3110.
Add the following sentence to 28.6.4.3[re.matchflag] paragraph 1:
1 The type
regex_constants::match_flag_typeis an implementation-defined bitmask type (17.5.2.1.3).Matching a regular expression against a sequence of characters [first,last) proceeds according to therules of the grammar specified for the regular expression object, modified according to the effects listed inTable 136 for any bitmask elements set.Typeregex_constants::match_flag_typealso defines the constantsregex_constants::match_defaultandregex_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 namesC0,C1, etc. representbitmask elements for this particularbitmask type. All suchnon-zero elements have distinct values such that, for any pairCi andCjwherei !=j,Ci & Ci is nonzeroandCi & 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 namesC0,C1, etc. representbitmask elements for this particularbitmask type. All such elements have distinct, nonzero values such that, for any pairCi andCjwherei !=j,Ci & Ci is nonzeroandCi & Cj is zero.Additionally, the value 0 is used to represent anempty 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_typeis an implementation-defined bitmask type (17.5.2.1.3).The constants of that type, except formatch_defaultandformat_default, are bitmaskelements. Thematch_defaultandformat_defaultconstants are empty bitmasks. Matchinga regular expression against a sequence of characters [first,last) proceeds according to the rules of thegrammar specified for the regular expression object, modified according to the effects listed in Table 136for any bitmask elements set.