@@ -124,7 +124,7 @@ SafePtr<T>::SafePtr(SafePtr<From>&& aSafeFrom) noexcept // mv - MtQ need
124124// - for safe_cast; constructor is faster; private is safe
125125template <typename T>
126126constexpr SafePtr<T>::SafePtr(std::shared_ptr<T>&& aPtr, const std::type_index& aReal, const std::type_index& aLast) noexcept
127- : pT_(aPtr) // mv
127+ : pT_(std::move( aPtr) ) // mv
128128 , realType_(pT_ ? aReal : typeid (T))
129129 , lastType_(pT_ ? aLast : typeid (T))
130130{}
@@ -175,18 +175,14 @@ template<typename T>
175175template <typename To>
176176std::type_index SafePtr<T>::genLastType_() const noexcept
177177{
178- if constexpr (std::is_same_v<To, void >) { // compile opt
179- HID (" T->void, recursive T.lastType_ is the most diff type before To=void" );
180- return lastType_; // eg Derive->Base->void = Base
181- }
182- else if (realType_ == typeid (To)) {
183- HID (" To->T->To, T.lastType is the most diff type" );
184- return lastType_; // eg Derive->Base->Derive = Base
185- }
186- else {
178+ if constexpr (!std::is_same_v<To, void >) {
179+ if (realType_ != typeid (To)) {
187180 HID (" most diff type=" << typeid (To).name ());
188181 return typeid (To); // eg Derive->Base = Base
182+ }
189183 }
184+ HID (" T->void, or To->T->To, T.lastType_ is the most diff type" );
185+ return lastType_; // eg Derive->Base->void = Base, Derive->Base->Derive = Base
190186}
191187
192188
0 commit comments