From 8291d41667b1a63d35bf818aaf9d75529e1f12f0 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 1 Aug 2012 14:41:43 +0200 Subject: Revert "sorted_vector: turn Find parameter into template" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3e3acee762fac71f7356ed1305a64e0278278081. It was a nice idea, but C++ is not yet ready for it; with the travesty of parametric polymorphism in C++ the find_unique inside the definition of find_unique actually refers to find_unique, so there is no way to actually refer to template find_unique inside its definition. Thanks to Luboš Luňák for explaining the problem to me. Somehow this does work in GCC 4.7 even with -std=c++98, likely by accident. --- o3tl/inc/o3tl/sorted_vector.hxx | 11 +++++------ o3tl/qa/test-sorted_vector.cxx | 6 ++++-- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'o3tl') diff --git a/o3tl/inc/o3tl/sorted_vector.hxx b/o3tl/inc/o3tl/sorted_vector.hxx index 6f444d90be14..4d442dd590ae 100644 --- a/o3tl/inc/o3tl/sorted_vector.hxx +++ b/o3tl/inc/o3tl/sorted_vector.hxx @@ -27,13 +27,12 @@ struct find_unique; @tpl Compare comparison method @tpl Find look up index of a Value in the array */ -template, - template class Find = find_unique > +template, + class Find = find_unique > class sorted_vector : private std::vector { private: - typedef Find Find_t; typedef typename std::vector base_t; typedef typename std::vector::iterator iterator; public: @@ -48,7 +47,7 @@ public: std::pair insert( const Value& x ) { - std::pair const ret(Find_t()(begin(), end(), x)); + std::pair const ret(Find()(begin(), end(), x)); if (!ret.second) { const_iterator const it = base_t::insert( @@ -60,7 +59,7 @@ public: size_type erase( const Value& x ) { - std::pair const ret(Find_t()(begin(), end(), x)); + std::pair const ret(Find()(begin(), end(), x)); if (ret.second) { base_t::erase(begin_nonconst() + (ret.first - begin())); @@ -130,7 +129,7 @@ public: */ const_iterator find( const Value& x ) const { - std::pair const ret(Find_t()(begin(), end(), x)); + std::pair const ret(Find()(begin(), end(), x)); return (ret.second) ? ret.first : end(); } diff --git a/o3tl/qa/test-sorted_vector.cxx b/o3tl/qa/test-sorted_vector.cxx index 8e9e719f2c1d..1b321c91a2a4 100644 --- a/o3tl/qa/test-sorted_vector.cxx +++ b/o3tl/qa/test-sorted_vector.cxx @@ -136,7 +136,8 @@ public: void testBasics_FindPtr() { o3tl::sorted_vector, - o3tl::find_partialorder_ptrequals> aVec; + o3tl::find_partialorder_ptrequals > > aVec; SwContent *p1 = new SwContent(1); SwContent *p2 = new SwContent(2); SwContent *p2_2 = new SwContent(2); @@ -194,7 +195,8 @@ public: void testErase_FindPtr() { o3tl::sorted_vector, - o3tl::find_partialorder_ptrequals> aVec; + o3tl::find_partialorder_ptrequals > > aVec; SwContent *p1 = new SwContent(1); SwContent *p1_2 = new SwContent(1); SwContent *p1_3 = new SwContent(1); -- cgit