Possible nb::init_implicit
breakage on MSVC due to initializer lists
#122
-
Hey! I am back with another question. I am porting over a C++ class from pybind wrapping a class Counter {
public:
...
double value;
Counter(double v = 0.): value(v) {}; In pybind, this was bound to Python with Since there is no
I did some googling and found out that this happens in initializer lists, and nanobind/include/nanobind/nb_class.h Lines 182 to 186 in fe3ecb8 Is there a way I can still enable implicit construction from both floats and ints in this case? I tried binding a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This only works for constructors that actually exist in your type. You will need a placement new constructor as described in |
Beta Was this translation helpful? Give feedback.
This only works for constructors that actually exist in your type. You will need a placement new constructor as described in
README.md
, along withnb::implicitly_convertible<float, Counter>()
.