オブジェクトIが互いに関連して使用される2つの方法有するAPIがあると仮定:ブーストshared_ptrのインタフェースは、/
boost::shared_ptr<IAsset> getAsset(const std::string & id);
void update(const Asset & asset);
を、私は別のクラスにboost::shared_ptr<Asset> asset
のメンバ変数を持っています。私が行う場合:
asset = otherObject->getAsset("first_asset");
// do some stuff
otherObject->update(*asset);
は私がのエラーを取得:
\boost\include\boost/smart_ptr/shared_ptr.hpp(378): error C2440: '<function-style-cast>' : cannot convert from 'boost::shared_ptr<T>' to 'boost::shared_ptr<T>'
with
[
T=IAsset
]
and
[
T=Asset
]
No constructor could take the source type, or constructor overload resolution was ambiguous
src\TestMethod.cpp(35) : see reference to function template instantiation 'boost::shared_ptr<T> &boost::shared_ptr<T>::operator =<IAsset>(boost::shared_ptr<IAsset> &&)' being compiled
with
[
T=Asset
]
\boost\include\boost/smart_ptr/shared_ptr.hpp(378): error C2228: left of '.swap' must have class/struct/union
を私はAsset
のためのクラス定義は、誰かが私に正しい方法を伝えることができclass Asset : virtual public IAsset {...}
のようIAsset
を拡張しないことをここで注意してください私は基礎となるAPIへのアクセス権がないので、これを行うには?