다음을 통해 공유


operator== <array>

Array comparison, equal.

template<Ty, std::size_t N>
    bool operator==(
        const array<Ty, N>& left,
        const array<Ty, N>& right);

Parameters

  • Ty
    The type of an element.

  • N
    The size of the array.

  • left
    Left container to compare.

  • right
    Right container to compare.

Remarks

The template function overloads operator== to compare two objects of template class array Class (TR1). The function returns equal(left.begin(), left.end(), right.begin()).

Example

 

// std_tr1__array__operator_eq.cpp 
// compile with: /EHsc 
#include <array> 
#include <iostream> 
 
typedef std::array<int, 4> Myarray; 
int main() 
    { 
    Myarray c0 = {0, 1, 2, 3}; 
 
// display contents " 0 1 2 3" 
    for (Myarray::const_iterator it = c0.begin(); 
        it != c0.end(); ++it) 
        std::cout << " " << *it; 
    std::cout << std::endl; 
 
    Myarray c1 = {4, 5, 6, 7}; 
 
// display contents " 4 5 6 7" 
    for (Myarray::const_iterator it = c1.begin(); 
        it != c1.end(); ++it) 
        std::cout << " " << *it; 
    std::cout << std::endl; 
 
// display results of comparisons 
    std::cout << std::boolalpha << " " << (c0 == c0); 
    std::cout << std::endl; 
    std::cout << std::boolalpha << " " << (c0 == c1); 
    std::cout << std::endl; 
 
    return (0); 
    } 
 
 0 1 2 3
 4 5 6 7
 true
 false

Requirements

Header: <array>

Namespace: std

See Also

Reference

array::begin

array::end

<array>

operator!= <array>

operator>= <array>

operator> <array>

operator< <array>

operator<= <array>

Other Resources

<array> Members