On Tue, Sep 9, 2008 at 5:15 PM, Peter Barker
On Tue, Sep 9, 2008 at 4:55 PM, Sean Farrow
wrote: Hi: I need to compare two vectors. I already have a function to compare two individual elements (std::bitsets) in this case. Can I use boost.foreach to do this, or is there a better way. I need to know whether vector one, is less than vector two.
Any help apreciated. Cheers Sean.
Just use == as you do with built in data types e.g.:
#include <vector> #include <iostream>
int main() { std::vector<int> v1; std::vector<int> v2;
if(v1 == v2) std::cout << "They're the same" << std::endl; }
Oops - sorry - I posted too quickly. Let's try again... Just use the < operator as you would with built in types. e.g.: #include <vector> #include <iostream> int main() { std::vector<int> v1; v1.push_back(5); std::vector<int> v2; v2.push_back(6); if(v1 < v2) std::cout << "v1 is smaller than v2" << std::endl; }