ac-library
ac-library copied to clipboard
Add operator bool to modint
It can be useful if you want something like:
mint x;
// ...
if (x)
do_sth(x);
https://github.com/atcoder/ac-library/pull/169/commits/95a6273bb67a1440dffe06687d62b13e12937abd
Strange to convert zero value to true.
For conversion rules between bool and int types in the C++ language,
https://timsong-cpp.github.io/cppwp/n4659/conv.prom#6
A prvalue of type
boolcan be converted to a prvalue of typeint, withfalsebecoming zero andtruebecoming one.
https://timsong-cpp.github.io/cppwp/n4659/conv.bool#1
A prvalue of arithmetic, unscoped enumeration, pointer, or pointer to member type can be converted to a prvalue of type
bool. A zero value, null pointer value, or null member pointer value is converted tofalse; any other value is converted totrue. For direct-initialization, a prvalue of typestd::nullptr_tcan be converted to a prvalue of typebool; the resulting value isfalse.