互いに組み合わせて使用される 2 つのメソッドを持つ API があるとします。
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
ここで、 のクラス定義は次のように拡張IAsset
されることに注意してください。class Asset : virtual public IAsset {...}
基になる API にアクセスできないため、誰かがこれを行う正しい方法を教えてもらえますか?