-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 11/10/2015 10:40 PM, L. David Baron wrote: >> One more thing may need to be done before more conversion comes: >> we need a typesafe way to declare bitmasks which we are using for >> several properties. I filed bug 1217241 for something similiar >> several weeks ago. > > I think mfbt/TypedEnumBits.h already does this.
As a heads-up, there's one slightly-awkward thing I've run into with TypedEnumBits.h's "MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS" magic: there's no implicit conversion to bool, when you try to put the result of a bitmask operation into a variable or function-arg. Specifically -- suppose I have "MyMaskType foo", and I want to test if it has the bit MyMaskType::SomeBit set. The compiler will happily accept this: if (foo | MyMaskType::SomeBit) But, the compiler rejects this: bool isBitSet = foo | MyMaskType::SomeBit; ...and more importantly, this: SomeFunctionWhichTakesABoolArg(foo | MyMaskType::SomeBit); The error looks like this, in clang: error: no viable conversion from 'mozilla::CastableTypedEnumResult<MyMaskType>' to 'bool' The compiler forces me to use "!!" or "bool(...)" to make the boolean conversion explicit in these latter two cases, which makes these type-safe masks a bit clumsier to work with. ~Daniel P.S. (I can work around this by adding an "operator bool" to the CastableTypedEnumResult type-definition in mfbt/TypedEnumBits.h. Maybe that's something we should do.) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJWQuyOAAoJEOxXkPfRs1MyqcAP/0xZG0iIpkiO5FTPdvsl+ZUM 23pS/sG1BiNOJ7NudIeRX0hGfgw47QUQNpZh/aKz+ZUengCu1n/Y+b+dxV2uIU/1 ZYz+tsHrd0rco/YhxS6HjlSr/Pl8d7jq6In0aKv7/E9BDyi6UrlxHq4t0S4VNSxT m1Y+q3vm+vQtrTvd7fznrrL0NQ2WJDsVcKEgZxO13sodeUsuPbDe5uXS6hJTnu6N uVmsDrP61dMw14s4CUTuli4AmYs2+jrSfrDBHl72kGszY7louMDqlvMsjJCFwbfa DlALtP2/8oM67+WEPr/YPulDSCrXT+8VeBCaBLi58noCEesP9sf+0e8Yxt2GX3LF yRqzqH/cvv2v4/6M3Hvd5W5RMDDVhuxfy8jKl4fTMDp5JCa8ponpE1wVFbgF7gF7 pzq1dnrkNEsEpP+IBhy0B6tBApeu1v5jqwPyzv0+D7QiHIm2tgSFDYEHXZ+GmJLn oyGtE2MGjBuMU+AiU0QSEvxWg9tQ3d92oYrUdxY5qGp+cl3Wujdy9H0188ZpLjTl 425vA8OSQFwxrLmxJDsK5Jg5+UgjwePRzSkOfE8JvYHk/hvVXkTo0/uC9/2W+GL1 gRYjTAspRYu+iwd4nNcT1tVwP2/1yGPaAr/0M/175BM76DGK8EJOsq2F6ICkZfKc f2Ev3jLL4cKFH4auExR5 =Rtti -----END PGP SIGNATURE----- _______________________________________________ dev-tech-layout mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-layout

