-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add support to Approx for comparison with constructible types #652
Comments
But |
I'll review my example and see if I can reproduce the problem I had. |
The issue is with explicitly constructible types (example now updated to make this clear). I'd like Catch's Approx to do the conversion for me. |
Then don't define the conversion operator |
The conversion operator is Defining I don't need Catch to solve this problem. I can define |
Makes sense.
That's evaluation in boolean context, which allows explicit conversion. See Contextual conversions
I think I'm finally starting to understand. So you're asking for something like: template<typename T> bool operator==(T const& lhs, Approx const& rhs)
{
return rhs == static_cast<double>(lhs);
}
// etc. |
That's right. I would add an enable_if to protect people from nasty compile errors. Does this belong in Catch or should I implement it myself? |
Only missing an update to |
@lightmare It will probably be missing for a while, until we figure out how to properly work with C++11 specific tests and features in approval tests. |
Approx is proving very useful to me. It would be more useful still if comparison between strong typedefs and Approx could be made to work without explicit conversions.
I'd be happy to do the work for this.
The text was updated successfully, but these errors were encountered: