Closed Bug 987253 Opened 10 years ago Closed 10 years ago

Add MFBT_EXPLICIT_CONVERSION_OPERATOR

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla31

People

(Reporter: bjacob, Assigned: bjacob)

References

Details

Attachments

(1 file)

I need this for something specific, which I'll file and make depend on this.
Attachment #8395793 - Flags: review?(jwalden+bmo)
Blocks: 987290
Comment on attachment 8395793 [details] [diff] [review]
MOZ_EXPLICIT_CONVERSION_OPERATOR

Review of attachment 8395793 [details] [diff] [review]:
-----------------------------------------------------------------

::: mfbt/Attributes.h
@@ +133,5 @@
> + * MOZ_EXPLICIT_CONVERSION_OPERATOR is a specifier on a type conversion
> + * overloaded operator that expands to 'explicit' if C++11 explicit conversion
> + * operators are supported, i.e. disallowing implicit conversions using this
> + * conversion operator. If C++11 explicit conversion operators are not supported
> + * then this expands to nothing.

Needs an example by it:

*   template<typename T>
*   class Ptr
*   {
*      T* ptr;
*      MOZ_EXPLICIT_CONVERSION_OPERATOR operator bool() { return ptr != nullptr; }
*   };

Also change the "expands to" language to discuss the *effect* of its expansions, and not what those expansions are.

Not to bikeshed names too hard, but maybe MOZ_EXPLICIT_CONVERSION only?  Users are going to spell out the operator part of this themselves.
Attachment #8395793 - Flags: review?(jwalden+bmo) → review+
https://hg.mozilla.org/mozilla-central/rev/1defae2eeae9
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla31
You need to log in before you can comment on or make changes to this bug.