From 96c2bc7e469a8322da66a071b2f721a6e3e02e65 Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 23 Dec 2016 14:01:19 -0800 Subject: [PATCH] modernize vector_utils.hpp --- include/libtorrent/vector_utils.hpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/include/libtorrent/vector_utils.hpp b/include/libtorrent/vector_utils.hpp index 7ff1ba50f..bd4bdba21 100644 --- a/include/libtorrent/vector_utils.hpp +++ b/include/libtorrent/vector_utils.hpp @@ -38,30 +38,20 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - template - typename std::vector::iterator sorted_find(std::vector& container - , T v) + template + auto sorted_find(Container& container, T const& v) + -> decltype(container.begin()) { - typename std::vector::iterator i = std::lower_bound(container.begin() - , container.end(), v); + auto i = std::lower_bound(container.begin(), container.end(), v); if (i == container.end()) return container.end(); if (*i != v) return container.end(); return i; } - template - typename std::vector::const_iterator sorted_find(std::vector const& container - , T const* v) - { - return sorted_find(const_cast&>(container) - , const_cast(v)); - } - template void sorted_insert(std::vector& container, T v) { - typename std::vector::iterator i = std::lower_bound(container.begin() - , container.end(), v); + auto i = std::lower_bound(container.begin(), container.end(), v); container.insert(i, v); } }