Platform::Array
オブジェクト内のアイテムのシーケンスを別のオブジェクトにコピーしたいPlatform::Array
。もちろん、たとえばfor
ループを使用してこれを解決できます。
int srcIdx = srcIdx0;
int destIdx = destIdx0;
for (int i = 0; i < count; ++i, ++srcIdx, ++destIdx)
dest[destIdx] = src[srcIdx];
私が疑問に思っているのは、C++/CX (コンポーネント拡張) にこの操作をより効率的に実行し、冗長性を減らすための組み込み機能があるかどうかです。
C# にはArray.Copyメソッドがあり、C++/CLI ではMarshal.Copyが少なくとも「プリミティブ」型をコピーするためのオプションになります。
C++ STL にはstd::copy
とがありstd::copy_n
ますが、これらのアルゴリズムはPlatform::Array
「反復子」begin()
とend()
.
どこかに「隠された」C++/CX の便利なコピー メソッドがありますか、またはfor
この操作のために明示的なループにフォールバックする必要がありますか?