3 ms·
Sure, but if you need it to work with actual reference-counted pointers from external callers, how could it be simpler? The Rust version doesn't have that abili
by jeffbee 4y ago
Sure, but if you need it to work with actual reference-counted pointers from external callers, how could it be simpler? The Rust version doesn't have that ability.
The best we could expect from this example is for the C++ compiler to deduce that the shared_ptr is irrelevant because the callee has internal linkage.
- codedokode 4y agoAs I understand, one cannot convert shared_ptr to unique_ptr, so if we declare an argument to add_two_numbers() as unique_ptr, then we won't be able to pass a shared_ptr to it.