[libc++]bitmask element ECMAScript is 0

When I was browsing regex header from libcxx, I found the following code:

enum syntax_option_type

{

icase = 1 << 0,

nosubs = 1 << 1,

optimize = 1 << 2,

collate = 1 << 3,

ECMAScript = 0,

basic = 1 << 4,

extended = 1 << 5,

awk = 1 << 6,

grep = 1 << 7,

egrep = 1 << 8

};

syntax_option_type is an implementation-defined bitmask type. According to standard, bitmask elements have distinct, nonzero values. And the value 0 is used to represent an empty bitmask, in which no bitmask elements are set.

Standard does mention that if no grammar element is set, the default grammar is ECMAScript. But ECMAScript still looks like a bitmask element inside of bitmask type syntax_option_type to me, which means it should be non-zero.

Interestingly, when I look at the history of regex header, ECMAScript was a non-zero value at some point, but got changed to 0 in a later commit.

So my questions are… Any reasons why we changed it to 0? (Maybe for cleaner implementation?) Is this still standard compliant? If not, should we modify it to be more standard compliant?

Thanks in advance!

Regards,

Jason Liu

When I was browsing regex header from libcxx, I found the following code:

enum syntax_option_type

{

    icase = 1 << 0,

    nosubs = 1 << 1,

    optimize = 1 << 2,

    collate = 1 << 3,

    ECMAScript = 0,

    basic = 1 << 4,

    extended = 1 << 5,

    awk = 1 << 6,

    grep = 1 << 7,

    egrep = 1 << 8

};

syntax_option_type is an implementation-defined bitmask type. According to
standard, bitmask elements have distinct, nonzero values. And the value 0
is used to represent an empty bitmask, in which no bitmask elements are
set.

Standard does mention that if no grammar element is set, the default
grammar is ECMAScript. But ECMAScript still looks like a bitmask element
inside of bitmask type syntax_option_type to me, which means it should be
non-zero.

Interestingly, when I look at the history of regex header, ECMAScript was
a non-zero value at some point, but got changed to 0 in a later commit.

So my questions are... Any reasons why we changed it to 0? (Maybe for
cleaner implementation?) Is this still standard compliant? If not, should
we modify it to be more standard compliant?

The use of "0" breaks use cases like the following:
bool isEcmaScript(::std::regex_constants::syntax_option_type v) {
  return v & ::std::regex_constants::ECMAScript;
}