[英]Is the a way to compare vector to be equal to part of another vector in C++?
If I have:如果我有:
A = {"one", "two", "three"} A = {“一”、“二”、“三”}
B = {"one", "two"} B = {“一”,“二”}
I want to avoid creating a new vector from A. Is there a way to use [A.begin(), A.begin()+1] to compare with B?我想避免从 A 创建一个新向量。有没有办法使用 [A.begin(), A.begin()+1] 与 B 进行比较?
There is a version of std::equal that could do:有一个 std::equal 版本可以做到:
template< class InputIt1, class InputIt2 >
bool equal( InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2 );
https://en.cppreference.com/w/cpp/algorithm/equal https://en.cppreference.com/w/cpp/algorithm/equal
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.