/* ----------------------------------------------------------------------- *//** * * @file Reference_impl.hpp * *//* ----------------------------------------------------------------------- */ #ifndef MADLIB_DBAL_REFERENCE_IMPL_HPP #define MADLIB_DBAL_REFERENCE_IMPL_HPP namespace madlib { namespace dbal { // Ref template Ref::Ref() : mPtr(NULL) { } template Ref::Ref(val_type* inPtr) : mPtr(inPtr) { } template Ref& Ref::rebind(val_type* inPtr) { mPtr = inPtr; return *this; } template Ref::operator val_type&() const { return *mPtr; } template typename Ref::val_type* Ref::ptr() const { return mPtr; } template bool Ref::isNull() const { return mPtr == NULL; } /** * @brief Copy operator is defined but protected, in order to prevent usage. */ template Ref& Ref::operator=(const Ref& inRef) { return *this; } // Ref template Ref::Ref() : Base() { } template Ref::Ref(val_type* inPtr) : Base(inPtr) { } template Ref& Ref::rebind(val_type* inPtr) { Base::rebind(inPtr); return *this; } template Ref::operator const val_type&() const { return Base::operator const val_type&(); } template Ref::operator val_type&() { return const_cast( static_cast(this)->operator const val_type&() ); } /** * @internal * It is important to define this operator because C++ will otherwise * perform an assignment as a bit-by-bit copy. Note that this default * operator= would be used even though there is a conversion path * through dest.operator=(orig.operator const val_type&()). */ template Ref& Ref::operator=(Ref& inRef) { *const_cast(mPtr) = inRef; return *this; } template Ref& Ref::operator=(const val_type& inValue) { *const_cast(mPtr) = inValue; return *this; } } // namespace dbal } // namespace madlib #endif // defined(MADLIB_DBAL_REFERENCE_IMPL_HPP)