Opened 13 years ago
Closed 13 years ago
#3117 closed Bugs (wontfix)
BOOST_CHECK requires !!x, fails if x is convertible to bool and disables operator!
Reported by: | Daniel Frey | Owned by: | Gennadiy Rozental |
---|---|---|---|
Milestone: | Boost 1.40.0 | Component: | test |
Version: | Boost 1.38.0 | Severity: | Problem |
Keywords: | Cc: |
Description
BOOST_CHECK( x ) requires !!x to be convertible to bool, although it should only require x to be convertible to bool. The problem can be seen in libs/utility/operators_test.cpp:661, where I had to convert the result of the comparison explicitly (as well as in many other places in this file).
The offending code is found in boost/test/predicate_result.hpp:53, and I don't actually see why this constructor is needed at all. It actually only makes sense for types which are not convertible to bool directly, but only through double negation.
I suggest to remove the constructor at line 53/54. If it breaks something, it means that this something is not convertible to bool and it should be fixed, instead of relying on BOOST_TEST to apply double negation.
Change History (3)
comment:1 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 13 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
I am inclined to leave it as is. Double negation is rather popular pattern and in majority of the cases does the right thing. I guess there is something special about your operator!, but you can always cast to bool explicitly.
So, unless if you can come up with the way to continue support types with only operator! implemented (using enable_if or something) we probably should keep it as is.
Boost.Test is C++ library. No need for macro. I've changed C style casts inside Boost.Test code. there might be still some coming from other components or system headers