Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++14 status.

1450. Contradiction inregex_constants

Section: 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 asios_base::adjustfield,ios_base::basefield andios_base::floatfield are 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_default should 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 typeregex_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 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_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 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 typeregex_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 bitmaskelements. Thematch_default andformat_default constants 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.


[8]ページ先頭

©2009-2026 Movatter.jp