Sdílet prostřednictvím


locale::operator()

Porovnává dva basic_string objektů.

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

Parametry

  • _Left
    Řetězec vlevo.

  • _Right
    Řetězec vpravo.

Vrácená hodnota

Funkce vrací člen:

  • –1, pokud je nižší než druhá řada porovnává první sekvence.

  • + 1, pokud druhá řada porovná méně než první řada.

  • 0, pokud jsou rovnocenné na sekvence.

Poznámky

Členské funkce účinně provádí:

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

Tedy jako funkce objektu můžete objekt národní prostředí.

Příklad

// 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;
}
  

Požadavky

Záhlaví: <locale>

Obor názvů: std

Viz také

Referenční dokumentace

locale Class