*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.*

**Section:** 28.5.2 [re.matchflag] **Status:** C++14
**Submitter:** BSI **Opened:** 2010-08-25 **Last modified:** 2016-02-10

**Priority: **3

**View all issues with** C++14 status.

**Discussion:**

**Addresses GB-127**

The Bitmask Type requirements in 15.4.2.1.4 [bitmask.types] p.3 say that
all elements on a bitmask type have distinct values, but
28.5.2 [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::basefieldandios_base::floatfieldare defined by 27.5.3.1.2 [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_defaultshould 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 15.4.2.1.4 [bitmask.types] p. 3:

for any pair

CiandCj,Ci&Ciis 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.5.2 [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 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_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 15.4.2.1.4 [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:

~~The~~A non-zero value Y is set in the object X if the expression X & Y is nonzero.

*[2014-02-13 Issaquah:]*

**Proposed resolution:**

Ammend 15.4.2.1.4 [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.5.2 [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 bitmask elements. Thematch_defaultandformat_defaultconstants 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.