char_traits::eq
测试两 char_type 字符是否相等。
static bool eq(
const char_type& _Ch1,
const char_type& _Ch2
);
参数
_Ch1
用于相等要测试的第一个字符。_Ch2
用于相等要测试的两个字符。
返回值
true,如果第一个字符与第二个字符相等;否则 false。
示例
// char_traits_eq.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';
// Testing for equality
bool b1 = char_traits<char>::eq ( ch1 , ch2 );
if ( b1 )
cout << "The character ch1 is equal "
<< "to the character ch2." << endl;
else
cout << "The character ch1 is not equal "
<< "to the character ch2." << endl;
// An equivalent and alternatively test procedure
if ( ch1 == ch3 )
cout << "The character ch1 is equal "
<< "to the character ch3." << endl;
else
cout << "The character ch1 is not equal "
<< "to the character ch3." << endl;
}
要求
标头: <string>
命名空间: std