operator== <array>

数组进行比较,该值等于。

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

参数

  • Ty
    元素的类型。

  • N
    数组大小。

  • left
    比较的容器。

  • right
    比较的正确的容器。

备注

模板函数重载模板比较两个对象的 operator== 类。array 类 (STL) 函数返回 equal(left.begin(), left.end(), right.begin())。

示例

 

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

要求

数组页眉: <>

命名空间: std

请参见

参考

array::begin

array::end

<array>

operator!= <array>

operator>= <array>

operator> <array>

operator< <array>

operator<= <array>