[glibmm] ArrayHandle: Make it compilable with MSVC 2005, 2008, 2010.



commit 693d26a51a758ad97c83f68f53dd3efc2d4058d2
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Mon Mar 28 11:17:02 2011 +0200

    ArrayHandle: Make it compilable with MSVC 2005, 2008, 2010.
    
    * glib/glibmm/arrayhandle.h: Put operator std::container methods
    definitions inside class template definition. Also added decrementation
    operators for ArrayHandleIterator for MSVC 2005.

 ChangeLog                 |    8 ++++
 glib/glibmm/arrayhandle.h |   95 ++++++++++++++++++++++++--------------------
 2 files changed, 60 insertions(+), 43 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0a385f2..6f05913 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-03-28  Krzesimir Nowak  <qdlacz gmail com>
+
+	ArrayHandle: Make it compilable with MSVC 2005, 2008, 2010.
+
+	* glib/glibmm/arrayhandle.h: Put operator std::container methods
+	definitions inside class template definition. Also added decrementation
+	operators for ArrayHandleIterator for MSVC 2005.
+
 2011-03-28  Murray Cumming  <murrayc murrayc com>
 
 	Variant: Use the VARIANT_TYPE_* constants.
diff --git a/glib/glibmm/arrayhandle.h b/glib/glibmm/arrayhandle.h
index e7d3e53..4db5647 100644
--- a/glib/glibmm/arrayhandle.h
+++ b/glib/glibmm/arrayhandle.h
@@ -182,6 +182,9 @@ public:
 
   inline ArrayHandleIterator<Tr> &     operator++();
   inline const ArrayHandleIterator<Tr> operator++(int);
+  // these are needed by msvc 2005 when using deque.
+  inline ArrayHandleIterator<Tr> &     operator--();
+  inline const ArrayHandleIterator<Tr> operator--(int);
 
   // All this random access stuff is only there because STL algorithms
   // usually have optimized specializations for random access iterators,
@@ -300,9 +303,42 @@ public:
   inline const_iterator begin() const;
   inline const_iterator end()   const;
 
-  template <class U> inline operator std::vector<U>() const;
-  template <class U> inline operator std::deque<U>()  const;
-  template <class U> inline operator std::list<U>()   const;
+  // this is inside class definition, so msvc 2005, 2008 and 2010 can compile this code.
+  template <class U> inline operator std::vector<U>() const
+  {
+#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
+    return std::vector<U>(this->begin(), this->end());
+#else
+    std::vector<U> temp;
+    temp.reserve(this->size());
+    Glib::Container_Helpers::fill_container(temp, this->begin(), this->end());
+    return temp;
+#endif
+  }
+
+  // this is inside class definition, so msvc 2005, 2008 and 2010 can compile this code.
+  template <class U> inline operator std::deque<U>() const
+  {
+#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
+    return std::deque<U>(this->begin(), this->end());
+#else
+    std::deque<U> temp;
+    Glib::Container_Helpers::fill_container(temp, this->begin(), this->end());
+    return temp;
+#endif
+  }
+
+  // this is inside class definition, so msvc 2005, 2008 and 2010 can compile this code.
+  template <class U> inline operator std::list<U>() const
+  {
+#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
+    return std::list<U>(this->begin(), this->end());
+#else
+    std::list<U> temp;
+    Glib::Container_Helpers::fill_container(temp, this->begin(), this->end());
+    return temp;
+#endif
+  }
 
   template <class Cont> inline
     void assign_to(Cont& container) const;
@@ -380,6 +416,19 @@ const ArrayHandleIterator<Tr> ArrayHandleIterator<Tr>::operator++(int)
 }
 
 template <class Tr> inline
+ArrayHandleIterator<Tr>& ArrayHandleIterator<Tr>::operator--()
+{
+  --pos_;
+  return *this;
+}
+
+template <class Tr> inline
+const ArrayHandleIterator<Tr> ArrayHandleIterator<Tr>::operator--(int)
+{
+  return ArrayHandleIterator<Tr>(pos_--);
+}
+
+template <class Tr> inline
 ArrayHandleIterator<Tr>&
 ArrayHandleIterator<Tr>::operator+=(typename ArrayHandleIterator<Tr>::difference_type rhs)
 {
@@ -658,46 +707,6 @@ ArrayHandle<bool,Container_Helpers::TypeTraits<bool> >::const_iterator ArrayHand
   return Glib::Container_Helpers::ArrayHandleIterator<Tr>(parray_ + size_);
 }
 
-template <class U>
-inline
-ArrayHandle<bool,Container_Helpers::TypeTraits<bool> >::operator std::vector<U>() const
-{
-#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
-  return std::vector<U>(this->begin(), this->end());
-#else
-  std::vector<U> temp;
-  temp.reserve(this->size());
-  Glib::Container_Helpers::fill_container(temp, this->begin(), this->end());
-  return temp;
-#endif
-}
-
-template <class U>
-inline
-ArrayHandle<bool,Container_Helpers::TypeTraits<bool> >::operator std::deque<U>() const
-{
-#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
-  return std::deque<U>(this->begin(), this->end());
-#else
-  std::deque<U> temp;
-  Glib::Container_Helpers::fill_container(temp, this->begin(), this->end());
-  return temp;
-#endif
-}
-
-template <class U>
-inline
-ArrayHandle<bool,Container_Helpers::TypeTraits<bool> >::operator std::list<U>() const
-{
-#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
-  return std::list<U>(this->begin(), this->end());
-#else
-  std::list<U> temp;
-  Glib::Container_Helpers::fill_container(temp, this->begin(), this->end());
-  return temp;
-#endif
-}
-
 template <class Cont>
 inline
 void ArrayHandle<bool,Container_Helpers::TypeTraits<bool> >::assign_to(Cont& container) const



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]