Closed sweemer closed 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
.
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?
Sounds good. I'll add those for both Handle and RelinkableHandle.
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
.
I'm getting
'QuantLib::Handle<T>::Handle': no overloaded function could convert all the argument types
when trying to use the constructor ofRelinkableHandle
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:Handle
does not provide a constructor taking a raw pointer and it's unclear whyRelinkableHandle
needs to.shared_ptr
takes ownership of the raw pointer, which may not be obvious from the constructor declaration, and can lead to double delete bugs.Also I changed a couple of places to pass by value and move.