<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 23, 2015 at 4:12 PM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>While looking at something unrelated (yay yak-shaving!) ... it came up that it may be convenient to actually re-use enumerations as bit masks in certain cases (assuming that the values are appropriately disjoint).</div><div><br></div><div>The thing is that enum classes are becoming more prevalent, and they are not simply usable in logical operations without casting.  The "solution" to this is replicate the enumeration.  The helper helps avoid the extensive casting by wrapping up the underlying type into a helper that simply provides the overloads for the normal (logical) operations.  It would also allow the re-use of the enumeration rather than duplicate the values.<br clear="all"><div><br></div><div>The implementation presented here should work with MSVC 2013, clang and GCC.  It is more of a proof of concept, that this is possible.  This thread is meant to raise the question of: is this a good idea?  Do we want to just use unsigned for bit masks instead?</div><div><br></div><div>(A thank you goes out to Aaron for a discussion on this idea and help with some of the nastier pieces of the metaprogramming here).</div><div><br></div><div>One point that I know will most definitely be brought up: the implicit boolean conversion.  Yes, its implicit, and yes that was an explicit choice.  The problem is that the use of logical operators as conditions is pretty extensive, so this conversion operator tends to be involved quite often, and would be needed to keep the idiomatic use in place.</div></div></div></blockquote><div><br></div><div><span style="font-size:12.8px">Seems that this idea came up again.  What does this add to my necromancy skills?</span></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span class=""><font color="#888888">-- <br><div>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</font></span></div></div>
</blockquote></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</div></div>