我收到以下錯誤,當試圖將一個派生類的boost::shared_ptr
轉換成父類的boost::shared_ptr
的:說明的boost :: sp_convertible
1>c:\program files\boost\boost_1_52_0\boost\smart_ptr\detail\sp_convertible.hpp(48) : error C2594: 'argument' : ambiguous conversions from 'Title_Id_Record *' to 'Component::Interface *'
1> c:\program files\boost\boost_1_52_0\boost\smart_ptr\detail\sp_convertible.hpp(66) : see reference to class template instantiation 'boost::detail::sp_convertible<Y,T>' being compiled
1> with
1> [
1> Y=Title_Id_Record,
1> T=Component::Interface
1> ]
這裏是繼承圖,根據Doxygen的,對於Title_Id_Record: (所有繼承是公共的。)
這裏是結構的文本:
template< class Y, class T > struct sp_convertible
{
typedef char (&yes) [1];
typedef char (&no) [2];
static yes f(T*);
static no f(...);
enum _vt { value = sizeof((f)(static_cast<Y*>(0))) == sizeof(yes) };
};
我的問題:
- 如何檢測 兼容性
boost::sp_convertible
結構工作? - 爲什麼升壓共享指針
Title_Id_Record
不可轉換 到共享指針Component::Interface
?
謝謝。
僅供參考,我在使用Boost 1.52.0的Windows Vista上使用Visual Studio 2008。
編輯1:SCCE
namespace Component
{
class Interface {};
}
namespace Record
{
class Interface
: public ::Component::Interface
{};
class Table_Association
: public Record::Interface
{};
class With_Id
: public Record::Table_Association
{};
class Of_Shared_Pointers
: public Record::Table_Association
{};
class Shared_Ptr_With_Id
: public Record::With_Id,
public Record::Of_Shared_Pointers
{};
class Shared_Ptr_Id_String
: public Record::Shared_Ptr_With_Id
{};
class Title_Id_Record
: public Record::Shared_Ptr_Id_String
{};
}
此圖上雙箭頭的含義是什麼? –