swap 関数 (auto_gcroot)

1 auto_gcroot と別のテーブルの間にあるオブジェクト。

template<typename _element_type>
void swap(
   auto_gcroot<_element_type> & _left,
   auto_gcroot<_element_type> & _right
);

パラメーター

  • _left
    auto_gcroot。

  • _right
    別の auto_gcroot。

使用例

// msl_swap_auto_gcroot.cpp
// compile with: /clr
#include <msclr\auto_gcroot.h>

using namespace System;
using namespace msclr;

int main() {
   auto_gcroot<String^> s1 = "string one";
   auto_gcroot<String^> s2 = "string two";

   Console::WriteLine( "s1 = '{0}', s2 = '{1}'",
      s1->ToString(), s2->ToString() );
   swap( s1, s2 );
   Console::WriteLine( "s1 = '{0}', s2 = '{1}'",
      s1->ToString(), s2->ToString() );
}
  

必要条件

ヘッダー ファイル <msclr \ auto_gcroot.h>

名前空間 の msclr

参照

関連項目

auto_gcroot

auto_gcroot::swap