Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nb::handle: make bool conversion explicit to avoid ambiguity with int…
…eger conversions in derived types (#173) An `explicit operator bool()` can still be used in conditional tests without a cast (`if (h) { ... }`) and is a better match for the explicitness of, for example, `operator int()` in `nb::int_`. Without this change, if you write ``` void fn(nb::int_ ival) { int i = ival; printf("%d\n", i); } ``` then `fn(nb::int_(42))` will print 1. (Only implicit conversions are allowed by the initialization style used, so the implicit `operator bool` in `nb::handle` is eligible while the explicit `operator int` in `nb::int_` is not.)
- Loading branch information