Closed Bug 1030515 Opened 5 years ago Closed 5 years ago

Make IsSigned and IsUnsigned usable with user-defined types

Categories

(Core :: MFBT, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: Waldo, Assigned: Waldo)

References

Details

Attachments

(1 file)

C++11 defined std::is_signed and std::is_unsigned as (is_arithmetic && T(-1) < T(0)) or similar.  But this implies that whatever T is, it has to be int-constructible in a sensible manner.  Which makes it useless for signedness testing in generic code.

This was apparently a defect, DR2197:

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2197

And according to that, existing implementations were already saying "no" for user-defined types, even when they wouldn't work with the C++11 definition exactly as written.

So it seems to me we should fix our implementation to be consistent with the defect resolution.  Patch approach mostly cribbed from the libstdc++ implementation.
Attached patch PatchSplinter Review
Attachment #8446275 - Flags: review?(nfroyd)
Blocks: 1030521
Attachment #8446275 - Flags: review?(nfroyd) → review+
https://hg.mozilla.org/mozilla-central/rev/e5864ea2d39e
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
You need to log in before you can comment on or make changes to this bug.