Currently shared_ptr and unique_ptr use implicit operator bool to be convertible to a bool value.
This causes some problems, such as:
shared_ptr<int> p(new int(10));
// ...
int x = p;
In this case p would be converted to a bool value and than converted to a int value, 0 or 1.
A better way is to define operator! and operator void*.
See: https://en.cppreference.com/w/cpp/language/implicit_conversion
Currently
shared_ptrandunique_ptruse implicitoperator boolto be convertible to aboolvalue.This causes some problems, such as:
In this case
pwould be converted to aboolvalue and than converted to aintvalue,0or1.A better way is to define
operator!andoperator void*.See: https://en.cppreference.com/w/cpp/language/implicit_conversion