- Notifications
You must be signed in to change notification settings - Fork254
Add operator bool to modint#169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Signed-off-by: szdytom <szdytom@qq.com>
mizar commentedAug 16, 2023
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
it is preferred to make conversion function explicit unless any reason not to do so.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This is the place where we need implicit conversion. no one wants to write |
yaito3014 commentedSep 8, 2024
You can write cf.https://en.cppreference.com/w/cpp/language/implicit_conversion#Contextual_conversions |
TumoiYorozu commentedSep 8, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This repositorydoes 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>structmint :publicmodint998244353 {using static_modint::static_modint;mint(modint998244353 m) : modint998244353 (m) {}operatorbool()const {returnval() !=0; }};intmain() { mintm(123);if (m) {puts("not zero"); }else {puts("zero"); }} |
It can be useful if you want something like: