#70 compilation issue if operator new is not public - simple body added but not needed on most compilers; MSVC and nvcc don't like a local struct not having a method defined when declared, since it can not be added later.
| 250 | // struct not having a method defined when declared, since it can not be |
| 251 | // added later. |
| 252 | struct PrivateOpNew { |
| 253 | int value = 1; |
| 254 | |
| 255 | private: |
| 256 | void *operator new(size_t bytes) { |
| 257 | void *ptr = std::malloc(bytes); |
| 258 | if (ptr) { |
| 259 | return ptr; |
| 260 | } |
| 261 | throw std::bad_alloc{}; |
| 262 | } |
| 263 | }; |
| 264 | py::class_<PrivateOpNew>(m, "PrivateOpNew").def_readonly("value", &PrivateOpNew::value); |
| 265 | m.def("private_op_new_value", []() { return PrivateOpNew(); }); |
| 266 | m.def( |
no outgoing calls