Share via


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) の 2 つのオブジェクトを比較します。 この関数は、lexicographical_compare(left.begin(), left.end(), right.begin()) を返します。

使用例

 

// std_tr1__array__operator_lt.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>

array::begin

array::end

operator== <array>

operator!= <array>

operator>= <array>

operator> <array>

operator<= <array>