locale::operator()

basic_string 개체를 비교합니다.

template<Class CharType, class Traits, class Allocator>
    bool operator()(
        const basic_string<CharType, Traits, Allocator >& _Left,
        const basic_string<CharType, Traits, Allocator >& _Right
    ) const;

매개 변수

  • _Left
    왼쪽 문자열입니다.

  • _Right
    오른쪽 문자열입니다.

반환 값

멤버 함수를 반환합니다.

  • 두 번째 시퀀스 보다 작은 첫 번째 시퀀스를 비교 하는 경우-1입니다.

  • 두 번째 시퀀스의 첫 번째 시퀀스 보다 비교 하면 + 1.

  • 시퀀스를 해당 하는 경우 0입니다.

설명

멤버 함수를 효과적으로 실행합니다.

const collate<CharType>& fac = use_fac<collate<CharType> >(*this);
return (fac.compare(_Left.begin( ),_Left.end( ),_Right.begin( ),_Right.end( )) < 0);

따라서 함수 개체로 로캘 개체를 사용할 수 있습니다.

예제

// locale_op_compare.cpp
// compile with: /EHsc
#include <iostream>
#include <string>
#include <locale>

int main( ) 
{
   using namespace std;
   wchar_t *sa = L"ztesting";
   wchar_t *sb = L"\0x00DFtesting";
   basic_string<wchar_t> a( sa );
   basic_string<wchar_t> b( sb );

   locale loc( "German_Germany" );
   cout << loc( a,b ) << endl;

   const collate<wchar_t>& fac = use_facet<collate<wchar_t> >( loc );
   cout << ( fac.compare( sa, sa + a.length( ),
       sb, sb + b.length( ) ) < 0) << endl;
}
  

요구 사항

헤더: <locale>

네임 스페이스: std

참고 항목

참조

locale Class