名前空間
変種
操作

operator==,!=,<,<=,>,>=(std::tuple)

提供: cppreference.com
< cpp‎ | utility‎ | tuple

 
 
ユーティリティライブラリ
支援を入力します (basic types, RTTI, type traits)
動的なメモリ管理
エラー処理
プログラムユーティリティ
可変個引数関数
日付と時刻
関数オブジェクト
initializer_list(C++11)
bitset
hash(C++11)
関係演算子
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
ペアとタプル
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
フォワード、スワップ、および移動
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
std::tuple
メンバ関数
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.
tuple::tuple
tuple::operator=
tuple::swap
非メンバ関数
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.
make_tuple
tie
forward_as_tuple
None
operator=
operator!=
operator<
operator<=
operator>
operator>=
std::swap
get
ヘルパークラス
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.
tuple_size
tuple_element
uses_allocator
ignore
 
Defined in header <tuple>
template< class... TTypes, class... UTypes >

bool operator==( const tuple<TTypes...>& lhs,

                 const tuple<UTypes...>& rhs );
(1) (C + + 11以来)
template< class... TTypes, class... UTypes >

bool operator!=( const tuple<TTypes...>& lhs,

                 const tuple<UTypes...>& rhs );
(2) (C + + 11以来)
template< class... TTypes, class... UTypes >

bool operator<( const tuple<TTypes...>& lhs,

                const tuple<UTypes...>& rhs );
(3) (C + + 11以来)
template< class... TTypes, class... UTypes >

bool operator<=( const tuple<TTypes...>& lhs,

                 const tuple<UTypes...>& rhs );
(5) (C + + 11以来)
template< class... TTypes, class... UTypes >

bool operator>( const tuple<TTypes...>& lhs,

                const tuple<UTypes...>& rhs );
(4) (C + + 11以来)
template< class... TTypes, class... UTypes >

bool operator>=( const tuple<TTypes...>& lhs,

                 const tuple<UTypes...>& rhs );
(6) (C + + 11以来)
1-2)
タプルlhsの対応する要素でタプルrhsのすべての要素を比較.
Original:
Compares every element of the tuple lhs with the corresponding element of the tuple rhs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3-6)
比較lhsrhs辞書的に、つまり、上のように、彼らが同等である場合、二番目の要素を比較し、それらが同等である場合には、第三の要素を比較し、最初の要素を比較.
Original:
Compares lhs and rhs lexicographically, that is, compares the first elements, if they are equivalent, compares the second elements, if those are equivalent, compares the third elements, and so on.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
全ての比較演算子は短絡されている、彼らは、比較の結果を決定することが必要であることを超えて、タプルの要素にアクセスしないでください.
Original:
All comparison operators are short-circuited; they do not access tuple elements beyond what is necessary to determine the result of the comparison.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

lhs, rhs -
比較するタプル
Original:
tuples to compare
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

1)
truestd::get<i>(lhs) == std::get<i>(rhs)[0, sizeof...(Types))内のすべてのiに対して、それ以外の場合false。 2空のタプルを返すためのtrue.
Original:
true if std::get<i>(lhs) == std::get<i>(rhs) for all i in [0, sizeof...(Types)), otherwise false. For two empty tuples returns true.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2) !(lhs == rhs)

3)
(bool)(std::get<0>(lhs) < std::get<0>(rhs)) || (!(bool)(std::get<0>(rhs) < std::get<0>(lhs)) && lhstail < rhstail)、どこlhstailをlhsは、その最初の要素なしで、rhstailは、その最初の要素のないRHSです。 2空のタプルの、返品false.
Original:
(bool)(std::get<0>(lhs) < std::get<0>(rhs)) || (!(bool)(std::get<0>(rhs) < std::get<0>(lhs)) && lhstail < rhstail), where lhstail is lhs without its first element, and rhstail is rhs without its first element. For two empty tuples, returns false.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

4) !(lhs < rhs)

5) rhs < lhs

6) !(rhs < lhs)

[編集]

演算子<がタプルを定義されているため、タプルの容器は並べ替えることができます.
Original:
Because operator< is defined for tuples, containers of tuples can be sorted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
int main()
{
    std::vector<std::tuple<int, std::string, float>> v;
    v.emplace_back(2, "baz", -0.1);
    v.emplace_back(2, "bar", 3.14);
    v.emplace_back(1, "foo", 100.1);
    std::sort(v.begin(), v.end());
 
    for(auto p: v) {
        std::cout << "(" << std::get<0>(p) << ", " << std::get<1>(p)
                  << ", " << std::get<2>(p) << ")\n";
    }
}

Output:

(1, foo, 100.1)
(2, bar, 3.14)
(2, baz, -0.1)

[編集] も参照してください