[Libreoffice-commits] .: o3tl/inc o3tl/qa sw/inc sw/source

Michael Stahl mst at kemper.freedesktop.org
Wed Aug 1 06:01:03 PDT 2012


 o3tl/inc/o3tl/sorted_vector.hxx   |   11 +++++------
 o3tl/qa/test-sorted_vector.cxx    |    6 ++++--
 sw/inc/docary.hxx                 |    2 +-
 sw/inc/ndhints.hxx                |    4 ++--
 sw/source/filter/html/htmlfly.hxx |    3 ++-
 sw/source/ui/utlui/content.cxx    |    3 ++-
 6 files changed, 16 insertions(+), 13 deletions(-)

New commits:
commit 8291d41667b1a63d35bf818aaf9d75529e1f12f0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Aug 1 14:41:43 2012 +0200

    Revert "sorted_vector: turn Find parameter into template"
    
    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<Value, Compare>, so there
    is no way to actually refer to template<Value, Compare> 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.

diff --git a/o3tl/inc/o3tl/sorted_vector.hxx b/o3tl/inc/o3tl/sorted_vector.hxx
index 6f444d9..4d442dd 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<typename Value, typename Compare = std::less<Value>,
-     template<typename, typename> class Find = find_unique >
+template<class Value, class Compare = std::less<Value>,
+         class Find = find_unique<Value, Compare> >
 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:
@@ -48,7 +47,7 @@ public:
 
     std::pair<const_iterator,bool> insert( const Value& x )
     {
-        std::pair<const_iterator, bool> const ret(Find_t()(begin(), end(), x));
+        std::pair<const_iterator, bool> 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_iterator, bool> const ret(Find_t()(begin(), end(), x));
+        std::pair<const_iterator, bool> 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_iterator, bool> const ret(Find_t()(begin(), end(), x));
+        std::pair<const_iterator, bool> 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 8e9e719..1b321c9 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<SwContent*, o3tl::less_ptr_to<SwContent>,
-            o3tl::find_partialorder_ptrequals> aVec;
+            o3tl::find_partialorder_ptrequals<SwContent*,
+                o3tl::less_ptr_to<SwContent> > > 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<SwContent*, o3tl::less_ptr_to<SwContent>,
-            o3tl::find_partialorder_ptrequals> aVec;
+            o3tl::find_partialorder_ptrequals<SwContent*,
+                o3tl::less_ptr_to<SwContent> > > aVec;
         SwContent *p1 = new SwContent(1);
         SwContent *p1_2 = new SwContent(1);
         SwContent *p1_3 = new SwContent(1);
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 4f9b9af..7c9f928 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -145,7 +145,7 @@ struct CompareSwRedlineTbl
 };
 class _SwRedlineTbl
     : public o3tl::sorted_vector<SwRedline*, CompareSwRedlineTbl,
-                o3tl::find_partialorder_ptrequals>
+        o3tl::find_partialorder_ptrequals<SwRedline*, CompareSwRedlineTbl> >
 {
 public:
     ~_SwRedlineTbl();
diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx
index 773bb1f..154c957 100644
--- a/sw/inc/ndhints.hxx
+++ b/sw/inc/ndhints.hxx
@@ -76,14 +76,14 @@ struct CompareSwpHtStart
     bool operator()(SwTxtAttr* const lhs, SwTxtAttr* const rhs) const;
 };
 class SwpHtStart : public o3tl::sorted_vector<SwTxtAttr*, CompareSwpHtStart,
-    o3tl::find_partialorder_ptrequals> {};
+    o3tl::find_partialorder_ptrequals<SwTxtAttr*, CompareSwpHtStart> > {};
 
 struct CompareSwpHtEnd
 {
     bool operator()(SwTxtAttr* const lhs, SwTxtAttr* const rhs) const;
 };
 class SwpHtEnd : public o3tl::sorted_vector<SwTxtAttr*, CompareSwpHtEnd,
-    o3tl::find_partialorder_ptrequals> {};
+    o3tl::find_partialorder_ptrequals<SwTxtAttr*, CompareSwpHtEnd> > {};
 
 // Class SwpHintsArr
 
diff --git a/sw/source/filter/html/htmlfly.hxx b/sw/source/filter/html/htmlfly.hxx
index 8184d5c..19b14e0 100644
--- a/sw/source/filter/html/htmlfly.hxx
+++ b/sw/source/filter/html/htmlfly.hxx
@@ -130,7 +130,8 @@ public:
 class SwHTMLPosFlyFrms
     : public o3tl::sorted_vector<SwHTMLPosFlyFrm*,
                 o3tl::less_ptr_to<SwHTMLPosFlyFrm>,
-                o3tl::find_partialorder_ptrequals>
+                o3tl::find_partialorder_ptrequals<SwHTMLPosFlyFrm*,
+                    o3tl::less_ptr_to<SwHTMLPosFlyFrm> > >
 {};
 
 #endif
diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx
index 9330f46..f150239 100644
--- a/sw/source/ui/utlui/content.cxx
+++ b/sw/source/ui/utlui/content.cxx
@@ -106,7 +106,8 @@ using namespace ::com::sun::star::container;
 
 class SwContentArr
     : public o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent>,
-                o3tl::find_partialorder_ptrequals>
+                o3tl::find_partialorder_ptrequals<SwContent*,
+                    o3tl::less_ptr_to<SwContent> > >
 {
 public:
     ~SwContentArr() { DeleteAndDestroyAll(); }


More information about the Libreoffice-commits mailing list