#ifndef id873715F57B504CCF8227CE03EA28CAFA #define id873715F57B504CCF8227CE03EA28CAFA #include "primitivetypes.hpp" #include #include #include #include namespace dk { namespace implem { template size_t get_index_from_pos ( const Vector& parPos, const Vector& parSize ) a_pure; template struct TypeWithQualifiers { typedef typename std::conditional::value && std::is_const::value, typename std::add_cv::type, typename std::conditional::value, typename std::add_volatile::type>::type, typename std::conditional::value, typename std::add_const::type>::type, typename std::remove_cv::type >::type >::type >::type result; }; #if defined(NDEBUG) template <> size_t get_index_from_pos<2> ( const Vector& parPos, const Vector& parSize ) a_pure; #endif template Vector buildPastEndCoordinate ( const Vector& parFrom, const Vector& parTo ) a_pure; } //namespace implem template ::type> class TileIterator : public boost::iterator_facade, T, boost::bidirectional_traversal_tag> { friend class boost::iterator_core_access; typedef std::vector vector_type; typedef typename implem::TypeWithQualifiers::result qualif_vector_type; public: typedef Vector coords; TileIterator ( void ); TileIterator ( const TileIterator& parOther ) = default; TileIterator ( TileIterator&& parOther ) = default; TileIterator ( qualif_vector_type* parData, const coords& parFrom, const coords& parTo ); TileIterator ( qualif_vector_type* parData, const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo ); ~TileIterator ( void ) = default; const coords& position ( void ) const { return m_pos; } private: void increment ( void ); void decrement ( void ); void advance ( size_t parAdvance ); ptrdiff_t distance_to ( const TileIterator& parOther ); bool equal ( const TileIterator& parOther ) const; T& dereference ( void ) const { return (*m_data)[get_current_index()]; } size_t get_current_index ( void ) const { return implem::get_index_from_pos(m_pos, m_areato - m_areafrom); } coords m_pos; coords m_from; coords m_to; coords m_areafrom; coords m_areato; qualif_vector_type* m_data; }; } //namespace dk #include "implem/tileiterator.inl" #endif