Skip to main content
5 events
when toggle format what by license comment
Mar 24, 2020 at 22:28 comment added monkey0506 @Caleth if you're using std::enable_if then you could use any compile-time constant constraint of your choosing, including a cherry-picked list of types to implement the operators for. There's nothing about that requirement, to only have bitwise operators for certain types, that precludes using templated overloads of free operators.
Mar 23, 2020 at 12:47 comment added Caleth @monkey0506 because you only want to define bitwise operators for some enums
Oct 26, 2016 at 7:50 comment added monkey0506 If you detest macros so much, why not use a proper C++ construct and write some template operators instead of the macros? Arguably, the template approach is better because you can use std::enable_if with std::is_enum to restrict your free operator overloads to only working with enumerated types. I've also added comparison operators (using std::underlying_type) and the logical not operator to further bridge the gap without losing the strong typing. The only thing I can't match is implicit conversion to bool, but flags != 0 and !flags are sufficient for me.
Aug 26, 2016 at 18:38 review First posts
Sep 25, 2016 at 18:40
Aug 26, 2016 at 18:38 history answered Mahmoud Al-Qudsi CC BY-SA 3.0