lballabio / QuantLib

The QuantLib C++ library
http://quantlib.org
Other
5k stars 1.73k forks source link

Deprecate RelinkableHandle constructor taking a raw pointer #1978

Closed sweemer closed 1 month ago

sweemer commented 1 month ago

I'm getting 'QuantLib::Handle<T>::Handle': no overloaded function could convert all the argument types when trying to use the constructor of RelinkableHandle that takes a raw pointer. Not sure if I'm doing it right, but even if it does work, I believe that this constructor should be deprecated for the following reasons:

Also I changed a couple of places to pass by value and move.

coveralls commented 1 month ago

Coverage Status

coverage: 72.55% (-0.001%) from 72.551% when pulling a19e2ec8867ddad4327cbb62d5486e0bcaf5e189 on sweemer:relinkable-handle into b9815104e787febc7e7483f92d79e0df52468b46 on lballabio:master.

sweemer commented 1 month ago

@lballabio Do you want me to revert these back to const reference too? Not sure whether you think that the case we want to optimize for is the same between shared_ptr and Handle.

lballabio commented 1 month ago

Hmm. We're dealing with just Handle and RelinkableHandle here, not a bazillion indexes, so we might consider overloading on const T& and T&&. What do you think?

sweemer commented 1 month ago

Sounds good. I'll add those for both Handle and RelinkableHandle.

sweemer commented 1 month ago

I added a default constructor for RelinkableHandle to disambiguate between the two new constructors, and also changed linkTo to pass by value, both of which are now in line with Handle.