/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * * All use of this software is subject to the terms of the revised BSD * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * * @file pointerTo.I * @author drose * @date 1999-02-10 */ /** * */ template ALWAYS_INLINE PointerTo:: PointerTo(To *ptr) noexcept : PointerToBase(ptr) { } /** * */ template INLINE PointerTo:: PointerTo(const PointerTo ©) : PointerToBase((const PointerToBase &)copy) { } /** * */ template INLINE PointerTo:: PointerTo(PointerTo &&from) noexcept : PointerToBase(std::move(from)) { } #ifndef CPPPARSER /** * */ template template ALWAYS_INLINE PointerTo:: PointerTo(Y *ptr) noexcept : PointerToBase(ptr) { } /** * */ template template ALWAYS_INLINE PointerTo:: PointerTo(const PointerTo &r) noexcept : PointerToBase(r.p()) { } /** * */ template template ALWAYS_INLINE PointerTo:: PointerTo(PointerTo &&r) noexcept : PointerToBase(std::move(r)) { } #endif // !CPPPARSER /** * */ template INLINE PointerTo &PointerTo:: operator = (PointerTo &&from) noexcept { this->reassign(std::move(from)); return *this; } #ifndef CPPPARSER /** * */ template template ALWAYS_INLINE PointerTo &PointerTo:: operator = (const PointerTo &r) noexcept { this->reassign(r.p()); return *this; } /** * */ template template ALWAYS_INLINE PointerTo &PointerTo:: operator = (PointerTo &&r) noexcept { this->reassign(std::move(r)); return *this; } #endif // !CPPPARSER /** * */ template constexpr typename PointerTo::To &PointerTo:: operator *() const noexcept { return *((To *)(this->_void_ptr)); } /** * */ template constexpr typename PointerTo::To *PointerTo:: operator -> () const noexcept { return (To *)(this->_void_ptr); } /** * We also have the typecast operator to automatically convert PointerTo's to * the required kind of actual pointer. This introduces ambiguities which the * compiler will resolve one way or the other, but we don't care which way it * goes because either will be correct. */ template constexpr PointerTo:: operator T * () const noexcept { return (To *)(this->_void_ptr); } /** * Returns a reference to the underlying pointer. This is a very unsafe * method. It's only used by some interrogate code. If you think this method * might be useful to you, you're probably wrong. * * Promise me you won't use this, okay? */ template INLINE T *&PointerTo:: cheat() { return (To *&)(this->_void_ptr); } /** * Returns an ordinary pointer instead of a PointerTo. Useful to work around * compiler problems, particularly for implicit upcasts. */ template constexpr typename PointerTo::To *PointerTo:: p() const noexcept { return (To *)(this->_void_ptr); } /** * */ template INLINE PointerTo &PointerTo:: operator = (To *ptr) { this->reassign(ptr); return *this; } /** * */ template INLINE PointerTo &PointerTo:: operator = (const PointerTo ©) { this->reassign((const PointerToBase &)copy); return *this; } /** * */ template ALWAYS_INLINE ConstPointerTo:: ConstPointerTo(const typename ConstPointerTo::To *ptr) noexcept : PointerToBase((typename ConstPointerTo::To *)ptr) { } /** * */ template INLINE ConstPointerTo:: ConstPointerTo(const PointerTo ©) : PointerToBase((const PointerToBase &)copy) { } /** * */ template INLINE ConstPointerTo:: ConstPointerTo(const ConstPointerTo ©) : PointerToBase((const PointerToBase &)copy) { } /** * */ template INLINE ConstPointerTo:: ConstPointerTo(PointerTo &&from) noexcept : PointerToBase(std::move(from)) { } /** * */ template INLINE ConstPointerTo:: ConstPointerTo(ConstPointerTo &&from) noexcept : PointerToBase(std::move(from)) { } #ifndef CPPPARSER /** * */ template template ALWAYS_INLINE ConstPointerTo:: ConstPointerTo(const Y *ptr) noexcept : PointerToBase((Y *)ptr) { } /** * */ template template ALWAYS_INLINE ConstPointerTo:: ConstPointerTo(const PointerTo &r) noexcept : PointerToBase(r.p()) { } /** * */ template template ALWAYS_INLINE ConstPointerTo:: ConstPointerTo(const ConstPointerTo &r) noexcept : PointerToBase((Y *)r.p()) { } /** * */ template template ALWAYS_INLINE ConstPointerTo:: ConstPointerTo(PointerTo &&r) noexcept : PointerToBase(std::move(r)) { } /** * */ template template ALWAYS_INLINE ConstPointerTo:: ConstPointerTo(ConstPointerTo &&r) noexcept : PointerToBase(std::move(r)) { } #endif // !CPPPARSER /** * */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (PointerTo &&from) noexcept { this->reassign(std::move(from)); return *this; } /** * */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (ConstPointerTo &&from) noexcept { this->reassign(std::move(from)); return *this; } #ifndef CPPPARSER /** * */ template template ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: operator = (const PointerTo &r) noexcept { this->reassign(r.p()); return *this; } /** * */ template template ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: operator = (const ConstPointerTo &r) noexcept { this->reassign((Y *)r.p()); return *this; } /** * */ template template ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: operator = (PointerTo &&r) noexcept { this->reassign(std::move(r)); return *this; } /** * */ template template ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: operator = (ConstPointerTo &&r) noexcept { this->reassign(std::move(r)); return *this; } #endif // !CPPPARSER /** * */ template constexpr const typename ConstPointerTo::To &ConstPointerTo:: operator *() const noexcept { return *((To *)(this->_void_ptr)); } /** * */ template constexpr const typename ConstPointerTo::To *ConstPointerTo:: operator -> () const noexcept { return (To *)(this->_void_ptr); } /** * We also have the typecast operator to automatically convert * ConstPointerTo's to the required kind of actual pointer. This introduces * ambiguities which the compiler will resolve one way or the other, but we * don't care which way it goes because either will be correct. */ template constexpr ConstPointerTo:: operator const T * () const noexcept { return (To *)(this->_void_ptr); } /** * Returns a reference to the underlying pointer. This is a very unsafe * method. It's only used by some interrogate code. If you think this method * might be useful to you, you're probably wrong. * * Promise me you won't use this, okay? */ template INLINE const T *&ConstPointerTo:: cheat() { return (const To *&)(this->_void_ptr); } /** * Returns an ordinary pointer instead of a ConstPointerTo. Useful to work * around compiler problems, particularly for implicit upcasts. */ template constexpr const typename ConstPointerTo::To *ConstPointerTo:: p() const noexcept { return (To *)(this->_void_ptr); } /** * */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (const To *ptr) { this->reassign((To *)ptr); return *this; } /** * */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (const PointerTo ©) { this->reassign((const PointerToBase &)copy); return *this; } /** * */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (const ConstPointerTo ©) { this->reassign((const PointerToBase &)copy); return *this; }