Conversation
Signed-off-by: szdytom <szdytom@qq.com>
|
95a6273 For conversion rules between bool and int types in the C++ language, https://timsong-cpp.github.io/cppwp/n4659/conv.prom#6
https://timsong-cpp.github.io/cppwp/n4659/conv.bool#1
|
yaito3014
left a comment
There was a problem hiding this comment.
it is preferred to make conversion function explicit unless any reason not to do so.
This is the place where we need implicit conversion. no one wants to write |
You can write cf. https://en.cppreference.com/w/cpp/language/implicit_conversion#Contextual_conversions |
|
This repository does not accept requests for new features.
In this case, I don't think it's necessary because you can add a custom bool cast as shown below: #include <atcoder/modint>
#include <bits/stdc++.h>
struct mint : public modint998244353 {
using static_modint::static_modint;
mint(modint998244353 m) : modint998244353 (m) {}
operator bool() const { return val() != 0; }
};
int main() {
mint m(123);
if (m) {
puts("not zero");
} else {
puts("zero");
}
} |
It can be useful if you want something like: