元组有一个隐式词典比较吗? [英] Do tuples have an implicit lexicographical comparison?
本文介绍了元组有一个隐式词典比较吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当排序例如一对向量:
vector<pair<int, double>> v;
sort(v.begin(), v.end());
您不需要指定排序条件就可以根据字典顺序对,因为,当不是elseway指定,一个词典比较适用。
You don't need to specify a sorting criterion to have a sorting based on the lexicographical order of the pairs since, when not elseway specified, a lexicographical comparison applies.
元组也有类似的行为标准吗?
Is a similar behaviour standard for tuples as well ?
在VS2012中,这会汇编
In VS2012 this compiles
vector<tuple<int, double, char>> tv;
sort(tv.begin(), tv.end());
但是它是标准强制这样做吗?
but is it standard mandated to do so ?
推荐答案
他们可以参见 operator ==,!= <,< =,>,> =(std :: tuple):
operator==
operator!=
operator<
operator<=
operator>
operator>=
按字母顺序比较元组中的值
lexicographically compares the values in the tuple
这篇关于元组有一个隐式词典比较吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文