diff options
author | Krzesimir Nowak <qdlacz@gmail.com> | 2011-03-28 11:17:02 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2011-03-29 09:02:18 +0200 |
commit | 693d26a51a758ad97c83f68f53dd3efc2d4058d2 (patch) | |
tree | 182c36575de35bd3c8b8173f2375b69a2e36c57b | |
parent | 6e127102c8176782bef2b18e070997c866386162 (diff) | |
download | glibmm-693d26a51a758ad97c83f68f53dd3efc2d4058d2.tar.gz |
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.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | glib/glibmm/arrayhandle.h | 95 |
2 files changed, 60 insertions, 43 deletions
@@ -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 e7d3e539..4db56470 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 |