Skip to content
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

explicit operator bool does not work with expect() #85

Closed
rianquinn opened this issue Nov 2, 2019 · 1 comment
Closed

explicit operator bool does not work with expect() #85

rianquinn opened this issue Nov 2, 2019 · 1 comment

Comments

@rianquinn
Copy link
Contributor

Expected Behavior

The following should compile and work:

    "test bool"_test = [] {
        std::unique_ptr<int> ptr;
        expect(ptr);
    };

Actual Behavior

This does not compile:

/home/user/working/bsl/tests/ifarray.cpp: In lambda function:
/home/user/working/bsl/tests/ifarray.cpp:66:19: error: no matching function for call to ‘expect(std::unique_ptr<int>&)’
   66 |         expect(ptr);
      |                   ^
In file included from /home/user/working/bsl/tests/ifarray.cpp:26:
/home/user/working/bsl/tests/ut.h:1606:9: note: candidate: ‘template<class TExpr, typename std::enable_if<(is_op_v<TExpr> || is_same_v<bool, TExpr>), int>::type <anonymous> > constexpr auto boost::ut::v1_0_0::expect(const TExpr&, const std::experimental::fundamentals_v2::source_location&)’
 1606 |         expect(
      |         ^~~~~~
/home/user/working/bsl/tests/ut.h:1606:9: note:   template argument deduction/substitution failed:
/home/user/working/bsl/tests/ut.h:1604:79: error: no type named ‘type’ in ‘struct std::enable_if<false, int>’
 1604 |                 type_traits::is_op_v<TExpr> or std::is_same_v<bool, TExpr>> = 0>
      |                                                                               ^
make[2]: *** [tests/CMakeFiles/test_ifarray.dir/build.make:63: tests/CMakeFiles/test_ifarray.dir/ifarray.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:246: tests/CMakeFiles/test_ifarray.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Steps to Reproduce the Problem

  1. Just compile the above test

Specifications

  • Version: master
  • Platform: Fedora 31
  • Subsystem: ???
@kris-jusiak
Copy link
Contributor

After some thoughts, I believe that explicitly convertible types should be explicitly static_cast'ed, however, implicit convertible ones should work, which is fixed now by #87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants