This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

668. money_get's empty minus sign

Section: 30.4.7.2.2 [locale.money.get.virtuals] Status: NAD Submitter: Thomas Plum Opened: 2007-04-16 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [locale.money.get.virtuals].

View all issues with NAD status.

Discussion:

30.4.7.2.2 [locale.money.get.virtuals], para 3 says:

If pos or neg is empty, the sign component is optional, and if no sign is detected, the result is given the sign that corresponds to the source of the empty string.

The following objection has been raised:

A negative_sign of "" means "there is no way to write a negative sign" not "any null sequence is a negative sign, so it's always there when you look for it".

[Plum ref _222612Y32]

[ Kona (2007): Bill to provide proposed wording and interpretation of existing wording. ]

Related to 669.

[ 2009-05-17 Howard adds: ]

I disagree that a negative_sign of "" means "there is no way to write a negative sign". The meaning requires the sentences of 30.4.7.2.2 [locale.money.get.virtuals] p3 following that quoted above to be taken into account:

-3- ... If pos or neg is empty, the sign component is optional, and if no sign is detected, the result is given the sign that corresponds to the source of the empty string. Otherwise, the character in the indicated position must match the first character of pos or neg, and the result is given the corresponding sign. If the first character of pos is equal to the first character of neg, or if both strings are empty, the result is given a positive sign.

So a negative_sign of "" means "there is no way to write a negative sign" only when positive_sign is also "". However when negative_sign is "" and postive_sign.size() > 0, then one writes a negative value by not writing the postive_sign in the position indicated by money_base::sign. For example:

pattern = {symbol, sign, value, none}
positive_sign = "+"
negative_sign = ""
$123   // a negative value, using optional sign
$+123  // a positive value
$-123  // a parse error

And:

pattern = {symbol, sign, value, none}
positive_sign = ""
negative_sign = ""
$123   // a positive value, no sign possible
$+123  // a parse error
$-123  // a parse error

And (regarding 669):

pattern = {symbol, sign, value, none}
positive_sign = "-"
negative_sign = "-"
$123   // a parse error, sign is mandatory
$+123  // a parse error
$-123  // a positive value

The text seems both unambiguous and clear to me. I recommend NAD for both this issue and 669. However I would have no objection to adding examples such as those above.

[ Batavia (2009-05): ]

This discussion applies equally to issue 669 (q.v.). Howard has added examples above, and recommends either NAD or a resolution that adds his (or similar) examples to the Working Paper.

Alan would like to rewrite paragraph 3.

We recommend moving to NAD. Anyone who feels strongly about adding the examples is invited to submit corresponding wording. We further recommend issue 669 be handled identically.

[ 2009-07-14 Alan reopens with improved wording. ]

[ 2009-07 Frankfurt ]

No consensus for closing as NAD. Leave in Review.

[ 2009-10 Santa Cruz: ]

NAD. Agreed that the original assessment as NAD was correct.

Proposed resolution:

Change 30.4.7.2.2 [locale.money.get.virtuals] p3:

-3- If the first character (if any) in the string pos returned by mp.positive_sign() or the string neg returned by mp.negative_sign() is recognized in the position indicated by sign in the format pattern, it is consumed and any remaining characters in the string are required after all the other format components. [Example: If showbase is off, then for a neg value of "()" and a currency symbol of "L", in "(100 L)" the "L" is consumed; but if neg is "-", the "L" in "-100 L" is not consumed. -- end example] If pos or neg is empty, the sign component is optional, and if no sign is detected, the result is given the sign that corresponds to the source of the empty string. Otherwise, the character in the indicated position must match the first character of pos or neg, and the result is given the corresponding sign. If the first character of pos is equal to the first character of neg, or if both strings are empty, the result is given a positive sign. The sign pattern strings pos and neg are returned by mp.positive_sign() and mp.negative_sign() respectively. A sign pattern is matched if its first character is recognized in s in the position indicated by sign in the format pattern, or if the pattern is empty and there is no sign recognized in s. A match is required to occur. If both patterns are matched, the result is given a positive sign, otherwise the result is given the sign corresponding to the matched pattern. If the pattern contains more than one character, the characters after the first must be matched in s after all other format components. If any sign characters are matched, s is consumed up to and including those characters. [Example: If showbase is off, then for a neg value of "()" and a currency symbol of "L", in "(100 L)" the entire string is consumed; but for a neg value of "-", in "-100 L", the string is consumed through the second "0" (the space and "L" are not consumed). — end example]