Well, you could still pass flag::none - the function address - to flag::operator&(). But of course you could then pass any function - with the same signature
Gottlob Frege sayeth: -
so none() might need a signature like none(some_special_type unused = 0) to prevent mistaken misuse.
Does that help?
Nial Douglass respondeth:
I thought of this too (specifically some_special_type<bits set for this flag>), but I realised I was getting into metaprogramming land.
I'm sure a "perfect" typesafe bitfield can finally be implemented as of C++ 14, but I think the likely implementation should be submitted as a N-paper to WG21 as an excellent example of what needs to be fixed in the C++ language. After all, typesafe bitfields ought to in a systems programming language!
A conference talk on building one of these might be very interesting ... nudge nudge! :)
+1 A "perfect typesafe bitfield" is very high value, and would make a great conference talk. --charley