char_traits::lt

测试一个字符是否比另一个小于。

static bool lt(
   const char_type& _Ch1, 
   const char_type& _Ch2 
);

参数

  • _Ch1
    为小于要测试的第一个字符比。

  • _Ch2
    为小于要测试的两个字符比。

返回值

true,如果第一个字符比第二个字符小于;否则 false

示例

// char_traits_lt.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 =  'z';

   // Testing for less than
   bool b1 = char_traits<char>::lt ( ch1 , ch2 );
   if ( b1 )
      cout << "The character ch1 is less than "
           << "the character ch2." << endl;
   else
      cout << "The character ch1 is not less "
           << "than the character ch2." << endl;

   // An equivalent and alternatively test procedure
   if ( ch3 <  ch2 )
      cout << "The character ch3 is less than "
           << "the character ch2." << endl;
   else
      cout << "The character ch3 is not less "
           << "than the character ch2." << endl;
}
  
  

要求

标头: <string>

命名空间: std

请参见

参考

char_traits Struct