From 22df4ad8f3bc2b2d5b95c5633beb4f987b1cca8d Mon Sep 17 00:00:00 2001 From: Yury Melnichek Date: Tue, 16 Aug 2011 11:22:42 +0200 Subject: [PATCH] Add lexicographical compare to algorithm.hpp and use in in buffer_vector. --- base/buffer_vector.hpp | 9 +-------- std/algorithm.hpp | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/base/buffer_vector.hpp b/base/buffer_vector.hpp index ca31a9f65d..cee3ab2175 100644 --- a/base/buffer_vector.hpp +++ b/base/buffer_vector.hpp @@ -257,12 +257,5 @@ inline bool operator!=(buffer_vector const & v1, buffer_vector con template inline bool operator<(buffer_vector const & v1, buffer_vector const & v2) { - const size_t N = std::min(v1.size(), v2.size()); - for (size_t i = 0; i < N; ++i) - { - if (!(v1[i] == v2[i])) - return v1[i] < v2[i]; - } - - return ((v1.size() != v2.size()) && (v1.size() == N)); + return lexicographical_compare(v1.begin(), v1.end(), v2.begin(), v2.end()); } diff --git a/std/algorithm.hpp b/std/algorithm.hpp index a570667e5f..6f5bbc8bb9 100644 --- a/std/algorithm.hpp +++ b/std/algorithm.hpp @@ -8,6 +8,7 @@ #include using std::equal; +using std::lexicographical_compare; using std::lower_bound; using std::max; using std::max_element;