char_traits::eq_int_type
Testet, ob zwei Zeichen, die als int_type s dargestellt werden oder nicht gleich sind.
static bool eq_int_type(
const int_type& _Ch1,
const int_type& _Ch2
);
Parameter
_Ch1
Das erste der beiden auf Gleichheit getestet werden Zeichen, als int_type S._Ch2
Das zweite der beiden auf Gleichheit getestet werden Zeichen, als int_type S.
Rückgabewert
true, wenn das erste Zeichen gleich das zweite Zeichen ist; andernfalls false.
Beispiel
// char_traits_eq_int_type.cpp
// compile with: /EHsc
#include <string>
#include <iostream>
int main( )
{
using namespace std;
char_traits<char>::char_type ch1 = 'x';
char_traits<char>::char_type ch2 = 'y';
char_traits<char>::char_type ch3 = 'x';
// Converting from char_type to int_type
char_traits<char>::int_type int1, int2 , int3;
int1 =char_traits<char>:: to_int_type ( ch1 );
int2 =char_traits<char>:: to_int_type ( ch2 );
int3 =char_traits<char>:: to_int_type ( ch3 );
cout << "The char_types and corresponding int_types are:"
<< "\n ch1 = " << ch1 << " corresponding to int1 = "
<< int1 << "."
<< "\n ch2 = " << ch2 << " corresponding to int1 = "
<< int2 << "."
<< "\n ch3 = " << ch3 << " corresponding to int1 = "
<< int3 << "." << endl << endl;
// Testing for equality of int_type representations
bool b1 = char_traits<char>::eq_int_type ( int1 , int2 );
if ( b1 )
cout << "The int_type representation of character ch1\n "
<< "is equal to the int_type representation of ch2."
<< endl;
else
cout << "The int_type representation of character ch1\n is "
<< "not equal to the int_type representation of ch2."
<< endl;
// An equivalent and alternatively test procedure
if ( int1 == int3 )
cout << "The int_type representation of character ch1\n "
<< "is equal to the int_type representation of ch3."
<< endl;
else
cout << "The int_type representation of character ch1\n is "
<< "not equal to the int_type representation of ch3."
<< endl;
}
Anforderungen
Header: <string>
Namespace: std