- //! Overloaded cast operator -- useful for implicit casts
- template <class U>
- operator smart_ptr<U>()
- {
- // This next line should provide a syntax check
- // to make sure that this cast makes sense.
- // If it doesn't, this should have a compiler error.
- // Otherwise, it should get optimized right out
- // of the code.
- //(U*)obj;
-
- return *reinterpret_cast<smart_ptr<U>*>(this);
- }