交换在一 auto_handle 之间的改变的对象。
template<typename _element_type>
void swap(
auto_handle<_element_type> % _left,
auto_handle<_element_type> % _right
);
参数
_left
一个 auto_handle。_right
另一个 auto_handle。
示例
// msl_swap_auto_handle.cpp
// compile with: /clr
#include <msclr\auto_handle.h>
using namespace System;
using namespace msclr;
int main() {
auto_handle<String> s1 = "string one";
auto_handle<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_handle.h>
命名空间 msclr