swap, fonction (auto_handle)
Échange des objets entre l’un et l’autre auto_handle
.
Syntaxe
template<typename _element_type>
void swap(
auto_handle<_element_type> % _left,
auto_handle<_element_type> % _right
);
Paramètres
_Gauche
Élément auto_handle
.
_Oui
Un autre auto_handle
.
Exemple
// 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() );
}
s1 = 'string one', s2 = 'string two'
s1 = 'string two', s2 = 'string one'
Spécifications
Fichier d’en-tête<msclr\auto_handle.h>
Espace de noms msclr
Voir aussi
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour