[fdo-dev] Pre-conditions and unsafe constuctions
Mateusz Loskot
mateusz at loskot.net
Thu Dec 7 14:37:23 EST 2006
Mateusz Loskot wrote:
> Brent Robinson wrote:
>>
>> In the FdoRdbmsMySqlConnection::NewSchemaManager()
>> example, a straight assignment:
>>
>> FdoSmPhMySqlMgrP physMgr = schMgr->GetPhysicalSchema();
>>
>> fails to compile. Something like the following would work:
>>
>> FdoSmPhMySqlMgrP physMgr =
>> FDO_SAFE_ADDREF(dynamic_cast<FdoSmPhMySqlMgr*>((FdoSmPhMgr*)
>> schMgr->GetPhysicalSchema());
>
> What is this C-cast for?
> Why not to provide raw pointer accessor, something like
> std::auto_ptr<T>::get(), then no dirty C casts are needed.
I've forgot there is FdoPtr<T>::p member, that provides
access to raw pointer.
So, no C-style is needed and the code can be cleaner:
dynamic_cast<FdoSmPhMySqlMgr*>(schMgr->GetPhysicalSchema().p);
AFAIK, the call schMgr->GetPhysicalSchema() returns smart-ptr
object FdoSmPhMgrP, and there is FdoSmPhMgrP::p which is
of type of FdoSmPhMgr*
Unless, there is some magic I don't see again ;-)
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net
More information about the Fdo_dev
mailing list