-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rm some offers where the quality is reduced #3827
Changes from all commits
e1bf2c9
8ad2fd5
9b8c050
d77ad06
a06ca4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,9 @@ class IOUAmount : private boost::totally_ordered<IOUAmount>, | |
{ | ||
return mantissa_; | ||
} | ||
|
||
static IOUAmount | ||
minPositiveAmount(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Long term, this could be made There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it were easy I'd do it, but this is going to be a rarely called function; making this |
||
}; | ||
|
||
std::string | ||
|
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.
The logic here just confuses me. First, is there a reason we don't use
(!std::is_same_v<TIn, IOUAmount> && !std::is_same_v<TOut, XRPAmount>)
? For that matter, why not just say what we, apparently, mean, which I think is:(std::is_same_v<TIn, XRPAmount> && std::is_same_v<TOut, IOUAmount>)
?Second, and maybe it's the fact that it's almost midnight, but I'm confused why the conditional is even necessary? Under what circumstances do we enter this codepath where
inIsXRP == true
butstd::is_same_v<TIn, XRPAmount> == false
?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.
There are three questions:
Why not
(!std::is_same_v<TIn, IOUAmount> && !std::is_same_v<TOut, XRPAmount>)
?Sometimes I write
!(error_condition1 || error_condition2)
instead of(!error_condition1 && !error_conditions2)
. Think of the huge savings by saving one fewer!
. More seriously, I don't have a strong preference; I find both about equally readable.Why not
(std::is_same_v<TIn, XRPAmount> && std::is_same_v<TOut, IOUAmount>)
?Because
TIn
can beXRPAmount
orSTAmount
, andTOut
can beIOUAmount
orSTAmount
.Why is the conditional even needed? Under what circumstances do we enter this codepath...?
While the codepath would never be executed, the template would still be instantiated, and we'd get compiler errors. In particular, we'd end up calling things like:
toAmount<IOUAmount>(xrpAmount);
Even though we know this will never be executed, the compiler will still try to compile that and we'd get a compiler error.Theif constexpr
prevents the template from being instantiated at all.I added some minor clarifying comments, but kept the code essentially the same. I can revisit if you still think this is confusing.