News for hackers. Stuff that matters.
Re:Type-safe Bitmasks in C++ by elteto on Wednesday June 13, 2018 @10:14AM (#17303219)
From the first comment on the page:

"The non-member function operator overloads that return bitmask<option_type> will not be considered for overload resolution if the enums are in a different namespace than the bitmask definition. The template deduction of operator| would not be sufficient since it does not trigger ADL from outside the namespace -- the overload must be available from within the scope where it used. This effectively requires a using directive or declaration to make them visible to participate in resolution (and at which, this will attempt to participate in resolution of any enum type where it may be considered a better match)."

Is this correct? Because if it is, C++ is bonkers...

Re:Type-safe Bitmasks in C++ by simias on Wednesday June 13, 2018 @10:50AM (#17303591)
C++ ADL is pretty bonkers indeed, or at least somewhat surprising if you don't know the rules very well. Thing is without ADL some patterns would be a lot harder to write (or use).

I personally dislike overloading very much so I'm probably not the best person to defend it though.

Re:Type-safe Bitmasks in C++ by MaxBarraclough on Wednesday June 13, 2018 @10:46AM (#17303562)
Deep dark arcane corner-cases in C++? Say it ain't so!