X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/3dddcdf2432e78f37c74d8c76c2c519a8d935ab2..bc7a59dded57338e9b5e523726b246dbdd4e0935:/apt-pkg/cacheset.h diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index 7c03ad97a..c790d4311 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -15,6 +15,7 @@ #if __cplusplus >= 201103L #include #include +#include #endif #include #include @@ -212,7 +213,7 @@ private: }; /*}}}*/ // Iterator templates for our Containers /*{{{*/ template class Container_iterator_base : - public std::iterator::iterator_category, container_iterator>, + public std::iterator::iterator_category, container_value>, public Interface::template iterator_base { protected: @@ -228,6 +229,7 @@ public: inline iterator_type& operator--() { --_iter;; return static_cast(*this); } inline iterator_type operator--(int) { iterator_type tmp(*this); operator--(); return tmp; } inline iterator_type operator-(typename container_iterator::difference_type const &n) { return iterator_type(_iter - n); } + inline typename container_iterator::difference_type operator-(iterator_type const &b) { return (_iter - b._iter); } inline iterator_type operator-=(typename container_iterator::difference_type const &n) { _iter -= n; return static_cast(*this); } inline bool operator!=(iterator_type const &i) const { return _iter != i._iter; } inline bool operator==(iterator_type const &i) const { return _iter == i._iter; } @@ -263,6 +265,7 @@ public: operator typename Master::const_iterator() { return typename Master::const_iterator(this->_iter); } inline iterator_type& operator=(iterator_type const &i) { this->_iter = i._iter; return static_cast(*this); } inline iterator_type& operator=(container_iterator const &i) { this->_iter = i; return static_cast(*this); } + inline typename Container::iterator::reference operator*(void) const { return *this->_iter; } inline typename Container::value_type getType(void) const { return *this->_iter; } }; @@ -289,6 +292,7 @@ public: operator typename Master::const_iterator() { return typename Master::const_iterator(this->_iter); } inline iterator_type& operator=(iterator_type const &i) { this->_iter = i._iter; return static_cast(*this); } inline iterator_type& operator=(container_iterator const &i) { this->_iter = i; return static_cast(*this); } + inline typename Container::reverse_iterator::reference operator*(void) const { return *this->_iter; } inline typename Container::value_type getType(void) const { return *this->_iter; } }; @@ -399,6 +403,14 @@ public: /*{{{*/ typedef Container_iterator iterator; typedef Container_const_reverse_iterator const_reverse_iterator; typedef Container_reverse_iterator reverse_iterator; + typedef typename Container::value_type value_type; + typedef typename Container::pointer pointer; + typedef typename Container::const_pointer const_pointer; + typedef typename Container::reference reference; + typedef typename Container::const_reference const_reference; + typedef typename Container::difference_type difference_type; + typedef typename Container::size_type size_type; + typedef typename Container::allocator_type allocator_type; bool insert(pkgCache::PkgIterator const &P) APT_OVERRIDE { if (P.end() == true) return false; _cont.insert(P); return true; } template void insert(PackageContainer const &pkgcont) { _cont.insert((typename Cont::const_iterator)pkgcont.begin(), (typename Cont::const_iterator)pkgcont.end()); } @@ -433,8 +445,15 @@ public: /*{{{*/ PackageContainer() : PackageContainerInterface(CacheSetHelper::UNKNOWN) {} explicit PackageContainer(CacheSetHelper::PkgSelector const &by) : PackageContainerInterface(by) {} APT_IGNORE_DEPRECATED_PUSH - APT_DEPRECATED PackageContainer(Constructor const &by) : PackageContainerInterface((CacheSetHelper::PkgSelector)by) {} + APT_DEPRECATED explicit PackageContainer(Constructor const &by) : PackageContainerInterface((CacheSetHelper::PkgSelector)by) {} APT_IGNORE_DEPRECATED_POP + template PackageContainer(Itr first, Itr last) : PackageContainerInterface(CacheSetHelper::UNKNOWN), _cont(first, last) {} +#if __cplusplus >= 201103L + PackageContainer(std::initializer_list list) : PackageContainerInterface(CacheSetHelper::UNKNOWN), _cont(list) {} + void push_back(value_type&& P) { _cont.emplace_back(std::move(P)); } + template void emplace_back(Args&&... args) { _cont.emplace_back(std::forward(args)...); } +#endif + void push_back(const value_type& P) { _cont.push_back(P); } /** \brief sort all included versions with given comparer @@ -644,7 +663,7 @@ template<> inline void PackageContainer >::in for (const_iterator p = begin; p != end; ++p) _cont.push_back(*p); } -#if __cplusplus < 201103L +#if APT_GCC_VERSION < 0x409 template<> inline PackageContainer >::iterator PackageContainer >::erase(iterator i) { _cont.erase(i._iter); return end(); @@ -695,6 +714,14 @@ public: inline pkgCache::PkgIterator getType(void) const { return _iter; } }; typedef const_iterator iterator; + typedef pkgCache::PkgIterator value_type; + typedef typename pkgCache::PkgIterator* pointer; + typedef typename pkgCache::PkgIterator const* const_pointer; + typedef const pkgCache::PkgIterator& const_reference; + typedef const_reference reference; + typedef const_iterator::difference_type difference_type; + typedef std::make_unsigned::type size_type; + bool empty() const APT_OVERRIDE { return false; } size_t size() const APT_OVERRIDE { return _cont->Head().PackageCount; } @@ -886,10 +913,19 @@ template class VersionContainer : public VersionContainerInterf pkgCache. */ Container _cont; public: /*{{{*/ + typedef Container_const_iterator const_iterator; typedef Container_iterator iterator; typedef Container_const_reverse_iterator const_reverse_iterator; typedef Container_reverse_iterator reverse_iterator; + typedef typename Container::value_type value_type; + typedef typename Container::pointer pointer; + typedef typename Container::const_pointer const_pointer; + typedef typename Container::reference reference; + typedef typename Container::const_reference const_reference; + typedef typename Container::difference_type difference_type; + typedef typename Container::size_type size_type; + typedef typename Container::allocator_type allocator_type; bool insert(pkgCache::VerIterator const &V) APT_OVERRIDE { if (V.end() == true) return false; _cont.insert(V); return true; } template void insert(VersionContainer const &vercont) { _cont.insert((typename Cont::const_iterator)vercont.begin(), (typename Cont::const_iterator)vercont.end()); } @@ -897,7 +933,7 @@ public: /*{{{*/ bool empty() const APT_OVERRIDE { return _cont.empty(); } void clear() APT_OVERRIDE { return _cont.clear(); } size_t size() const APT_OVERRIDE { return _cont.size(); } -#if __GNUC__ >= 5 || (__GNUC_MINOR__ >= 9 && __GNUC__ >= 4) +#if APT_GCC_VERSION >= 0x409 iterator erase( const_iterator pos ) { return iterator(_cont.erase(pos._iter)); } iterator erase( const_iterator first, const_iterator last ) { return iterator(_cont.erase(first._iter, last._iter)); } #else @@ -920,6 +956,15 @@ public: /*{{{*/ reverse_iterator rend() { return reverse_iterator(_cont.rend()); } const_iterator find(pkgCache::VerIterator const &V) const { return const_iterator(_cont.find(V)); } + VersionContainer() : VersionContainerInterface() {} + template VersionContainer(Itr first, Itr last) : VersionContainerInterface(), _cont(first, last) {} +#if __cplusplus >= 201103L + VersionContainer(std::initializer_list list) : VersionContainerInterface(), _cont(list) {} + void push_back(value_type&& P) { _cont.emplace_back(std::move(P)); } + template void emplace_back(Args&&... args) { _cont.emplace_back(std::forward(args)...); } +#endif + void push_back(const value_type& P) { _cont.push_back(P); } + /** \brief sort all included versions with given comparer Some containers are sorted by default, some are not and can't be, @@ -1148,7 +1193,7 @@ template<> inline void VersionContainer >::in for (const_iterator v = begin; v != end; ++v) _cont.push_back(*v); } -#if __cplusplus < 201103L +#if APT_GCC_VERSION < 0x409 template<> inline VersionContainer >::iterator VersionContainer >::erase(iterator i) { _cont.erase(i._iter); return end();