diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-08-02 21:30:45 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-08-02 22:12:07 +0200 |
commit | ebd2bfa2e748d9efa4ee759f5b9003d9e470d752 (patch) | |
tree | f892cf1cec026b077fbe991dc2ce27e6c315458d /o3tl/inc | |
parent | 285a5ae06cf51927c2df4b47043e51394aab98b7 (diff) |
Revert "Revert "sorted_vector: turn Find parameter into template""
This reverts commit 8291d41667b1a63d35bf818aaf9d75529e1f12f0.
Un-revert that, with a tweak: with the bizarre name lookup semantics
in C++, the proper way to refer to a template (as opposed to a template
instance) is by prefixing the name with its namespace, which does seem
to work with MSVC2008 & GCC 4.7; thanks to Stephan Bergmann for the hint.
Change-Id: Id9cccbe68fb3ce2dd070c4b3dbd21782c92170ca
Diffstat (limited to 'o3tl/inc')
-rw-r--r-- | o3tl/inc/o3tl/sorted_vector.hxx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/o3tl/inc/o3tl/sorted_vector.hxx b/o3tl/inc/o3tl/sorted_vector.hxx index 4d442dd590ae..90aacbf11ac7 100644 --- a/o3tl/inc/o3tl/sorted_vector.hxx +++ b/o3tl/inc/o3tl/sorted_vector.hxx @@ -27,12 +27,13 @@ struct find_unique; @tpl Compare comparison method @tpl Find look up index of a Value in the array */ -template<class Value, class Compare = std::less<Value>, - class Find = find_unique<Value, Compare> > +template<typename Value, typename Compare = std::less<Value>, + template<typename, typename> class Find = find_unique > class sorted_vector : private std::vector<Value> { private: + typedef Find<Value, Compare> Find_t; typedef typename std::vector<Value> base_t; typedef typename std::vector<Value>::iterator iterator; public: @@ -47,7 +48,7 @@ public: std::pair<const_iterator,bool> insert( const Value& x ) { - std::pair<const_iterator, bool> const ret(Find()(begin(), end(), x)); + std::pair<const_iterator, bool> const ret(Find_t()(begin(), end(), x)); if (!ret.second) { const_iterator const it = base_t::insert( @@ -59,7 +60,7 @@ public: size_type erase( const Value& x ) { - std::pair<const_iterator, bool> const ret(Find()(begin(), end(), x)); + std::pair<const_iterator, bool> const ret(Find_t()(begin(), end(), x)); if (ret.second) { base_t::erase(begin_nonconst() + (ret.first - begin())); @@ -129,7 +130,7 @@ public: */ const_iterator find( const Value& x ) const { - std::pair<const_iterator, bool> const ret(Find()(begin(), end(), x)); + std::pair<const_iterator, bool> const ret(Find_t()(begin(), end(), x)); return (ret.second) ? ret.first : end(); } @@ -180,8 +181,8 @@ template <class T> struct less_ptr_to : public std::binary_function <T*,T*,bool> template<class Value, class Compare> struct find_unique { - typedef typename sorted_vector<Value, Compare, find_unique> - ::const_iterator const_iterator; + typedef typename sorted_vector<Value, Compare, + o3tl::find_unique> ::const_iterator const_iterator; std::pair<const_iterator, bool> operator()( const_iterator first, const_iterator last, Value const& v) @@ -197,8 +198,8 @@ struct find_unique template<class Value, class Compare> struct find_partialorder_ptrequals { - typedef typename sorted_vector<Value, Compare, find_partialorder_ptrequals> - ::const_iterator const_iterator; + typedef typename sorted_vector<Value, Compare, + o3tl::find_partialorder_ptrequals>::const_iterator const_iterator; std::pair<const_iterator, bool> operator()( const_iterator first, const_iterator last, Value const& v) |