I'm subclassing std::optional and need to delete the operator==(bool) and implement my custom operator==(enum).
To delete the operator, this worked:
constexpr bool operator == ( bool ) noexcept = delete; Works great for the code below, throwing a "deleted function" compile error
OptionalSubclass<int> ReturnEvens( int i ) { if ( i % 2 == 0 ) return i; return {}; } : : auto result = ReturnEvens(42); if ( result == true ) std::cout << *result << " is even" << std::endl; However, the below code, with an implied 'true', compiles and executes
auto result = ReturnEvens(42); if ( result ) std::cout << *result << " is even" << std::endl; Is there a different operator I should be deleting?
std::optional<int>rather than your new derived class. Is that deliberate?