Espaces de noms
Variantes
Affichages
Actions

std::basic_string::compare

De cppreference.com
< cpp‎ | string‎ | basic string

 
 
Bibliothèque de chaînes de caractères
Chaînes à zéro terminal
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Les chaînes d'octets
Chaines multi-octets
Les chaînes étendues
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
std::basic_string
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::basic_string
basic_string::operator=
basic_string::assign
basic_string::get_allocator
Elément d'accès
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::at
basic_string::operator[]
basic_string::front (C++11)
basic_string::back (C++11)
basic_string::data
basic_string::c_str
Les itérateurs
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::begin
basic_string::cbegin

(C++11)
basic_string::end
basic_string::cend

(C++11)
basic_string::rbegin
basic_string::crbegin

(C++11)
basic_string::rend
basic_string::crend

(C++11)
Capacité
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::empty
basic_string::size
basic_string::length
basic_string::max_size
basic_string::reserve
basic_string::capacity
basic_string::shrink_to_fit (C++11)
Opérations
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::clear
basic_string::insert
basic_string::erase
basic_string::push_back
basic_string::pop_back (C++11)
basic_string::append
basic_string::operator+=
basic_string::compare
basic_string::replace
basic_string::substr
basic_string::copy
basic_string::resize
basic_string::swap
Recherche
Original:
Search
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::find
basic_string::rfind
basic_string::find_first_of
basic_string::find_first_not_of
basic_string::find_last_of
basic_string::find_last_not_of
Constantes
Original:
Constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::npos
Tiers fonctions
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator+
operator==
operator!=
operator<
operator>
operator<=
operator>=
swap(std::basic_string)
operator<<
operator>>
getline
stoi
stol
stoll
(C++11)
(C++11)
(C++11)
stoul
stoull
(C++11)
(C++11)
stof
stod
stold
(C++11)
(C++11)
(C++11)
to_string (C++11)
to_wstring (C++11)
Classes d'aide
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
hash<std::string>
hash<std::wstring>
hash<std::u32string>
hash<std::u16string>
(C++11)
 
int compare( const basic_string& str ) const;
(1)
int compare( size_type pos1, size_type count1,
             const basic_string& str ) const;
(2)
int compare( size_type pos1, size_type count1,

             const basic_string& str,

             size_type pos2, size_type count2 ) const;
(3)
int compare( const CharT* s ) const noexcept;
(4)
int compare( size_type pos1, size_type count1,
             const CharT* s ) const;
(5)
int compare( size_type pos1, size_type count1,
             const CharT* s, size_type count2 ) const;
(6)
Compare deux séquences de caractères .
Original:
Compares two character sequences.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
Compare cette chaîne str'. Tout d'abord, calcule le nombre de caractères à comparer, comme par size_type rlen = std::min(size(), str.size()). Compare ensuite en appelant Traits::compare(data(), str.data(), rlen). Pour les chaînes standards de cette fonction effectue caractère par caractère comparaison lexicographique. Si le résultat est égal à zéro (les chaînes sont égales à ce jour), leurs tailles sont comparés comme suit:
Original:
Compares this string to str. First, calculates the number of characters to compare, as if by size_type rlen = std::min(size(), str.size()). Then compares by calling Traits::compare(data(), str.data(), rlen). For standard strings this function performs character-by-character lexicographical comparison. If the result is zero (the strings are equal so far), then their sizes are compared as follows:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Condition Result Return value
Traits::compare(data, arg, rlen) < 0 data is less than arg <0
Traits::compare(data, arg, rlen) == 0 size(data) < size(arg) data is less than arg <0
size(data) == size(arg) data is equal to arg 0
size(data) > size(arg) data is greater than arg >0
Traits::compare(data, arg, rlen) > 0 data is greater than arg >0
2)
Compare une chaîne [pos1, pos1+count1) de cette chaîne str' comme par basic_string(*this, pos1, count1).compare(str)
Original:
Compares a [pos1, pos1+count1) substring of this string to str as if by basic_string(*this, pos1, count1).compare(str)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Compare une chaîne [pos1, pos1+count1) de cette chaîne à une chaîne de [pos2, pas2+count2)' str comme par basic_string(*this, pos1, count1).compare(basic_string(str, pos2, count2))
Original:
Compares a [pos1, pos1+count1) substring of this string to a substring [pos2, pas2+count2) of str as if by basic_string(*this, pos1, count1).compare(basic_string(str, pos2, count2))
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Compare cette chaîne au début terminée par NULL séquence de caractères par le caractère pointé par s', comme par compare(basic_string(s))
Original:
Compares this string to the null-terminated character sequence beginning at the character pointed to by s, as if by compare(basic_string(s))
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
Compare une chaîne [pos1, pos1+count1) de cette chaîne au début terminée par NULL séquence de caractères par le caractère pointé par s', comme par basic_string(*this, pos, count1).compare(basic_string(s))
Original:
Compares a [pos1, pos1+count1) substring of this string to the null-terminated character sequence beginning at the character pointed to by s, as if by basic_string(*this, pos, count1).compare(basic_string(s))
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
Compare une chaîne [pos1, pos1+count1) de cette chaîne de caractères count2 premiers du tableau de caractères dont le premier caractère est souligné par l', comme par basic_string(*this, pos, count1).compare(basic_string(s, count2)). (Remarque: les caractères de s à s+count2 peuvent inclure des caractères nuls))
Original:
Compares a [pos1, pos1+count1) substring of this string to the first count2 characters of the character array whose first character is pointed to by s, as if by basic_string(*this, pos, count1).compare(basic_string(s, count2)). (Note: the characters from s to s+count2 may include null characters))
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Sommaire

[modifier] Paramètres

str -
autre chaîne à comparer
Original:
other string to compare to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
s -
pointeur vers la chaîne de caractères à comparer
Original:
pointer to the character string to compare to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
count1 -
nombre de caractères de cette chaîne à compore
Original:
number of characters of this string to compore
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pos1 -
position du premier caractère de cette chaîne à comparer
Original:
position of the first character in this string to compare
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
count2 -
nombre de caractères de la chaîne donnée compore
Original:
number of characters of the given string to compore
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pos2 -
la position du premier caractère de la chaîne donnée à comparer
Original:
position of the first character of the given string to compare
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Retourne la valeur

valeur négative si cette chaîne est moins de la séquence de caractères autre, zéro si les deux séquences de caractères sont égaux, la valeur positive si cette chaîne est plus que la séquence de caractères autre .
Original:
negative value if this string is less than the other character sequence, zero if the both character sequences are equal, positive value if this string is greater than the other character sequence.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Exceptions

1)
noexcept specification:  
noexcept
   (depuis C++11)
2-6)
Peut lever les exceptions lancées par les constructeurs basic_string correspondantes .
Original:
May throw the exceptions thrown by the corresponding basic_string constructors.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Mise en œuvre possible

template<class CharT, class Traits, class Alloc>
int basic_string<CharT, Traits, Alloc>::compare(const std::basic_string& str) const noexcept
{
    size_type lhs_sz = size();
    size_type rhs_sz = str.size();
    int result = traits_type::compare(data(), str.data(), std::min(lhs_sz, rhs_sz));
    if (result != 0)
        return result;
    if (lhs_sz < rhs_sz)
        return -1;
    if (lhs_sz > rhs_sz)
        return 1;
    return 0;
}

[modifier] Exemple

[modifier] Voir aussi

compare lexicographiquement deux chaînes
Original:
lexicographically compares two strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
renvoie une sous-chaîne
Original:
returns a substring
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
définit comparaison lexicographique et le hachage de chaînes
Original:
defines lexicographical comparison and hashing of strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe générique) [edit]
compare deux chaînes en fonction de la localisation en cours
Original:
compares two strings in accordance to the current locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction) [edit]