IVector^ から Vector^ に変換するにはどうすればよいですか? ドキュメンテーションは、暗黙的に動作する逆の状況をカバーしていますが、これは暗黙的な変換を試みてコンパイルするとコンパイルされませんが、キャストしようとすると例外が発生します。リファレンスを調べましたが、これをカバーできませんでした。
この理由は、Vector^ をクラス内に格納し、Vector はより高速に動作し、内部計算に使用する必要があるため、JavaScript と通信するためのプロパティでのみ IVector を使用したいからです。
ありがとう
編集: 簡潔すぎて申し訳ありません。状況のより広い説明は次のとおりです。
if(parent->childNodes != nullptr && parent->childNodes->Size > 0)
{
for (uint32 i = 0; i < parent->childNodes->Size; i++)
{
ContentElementsNode^ childNode;
IVector<ContentElementsNode^>^ childNodes = parent->childNodes;
childNode = childNodes->GetAt(i);
Vector<ContentElementsNode^>^ childWords = wordObjects(childNode);
for each (ContentElementsNode^ word in childWords)
result->Append(word);
}
}
関数は GetAt(i) 行の最初の呼び出しで失敗します。IVector に問題があるのではないかと考えたので、代わりに Vector を使用しようとしましたが、キャストできませんでした。ContentElementsNode 宣言は次のとおりです。
public ref class ContentElementsNode sealed
{
private:
IVector<ContentElementsNode^>^ childNodes_;
String^ textContent_;
String^ localName_;
Rectangle boundingBox_;
String^ id_;
public:
ContentElementsNode(void);
property IVector<ContentElementsNode^>^ childNodes {
void set(IVector<ContentElementsNode^>^ value)
{
childNodes_ = value;
}
IVector<ContentElementsNode^>^ get()
{
return childNodes_;
}
}
property String^ textContent {
String^ get() {
return textContent_;
}
void set(String^ value) {
textContent_ = value;
}
}
property String^ localName {
String^ get() {
return localName_;
}
void set(String^ value) {
localName_ = value;
}
}
property Rectangle boundingBox {
Rectangle get() {
return boundingBox_;
}
void set(Rectangle value) {
boundingBox_ = value;
}
}
property String^ id {
String^ get() {
return id_;
}
void set(String^ value) {
id_ = value;
}
}
};