diff --git a/include/boost/unordered/detail/foa/table.hpp b/include/boost/unordered/detail/foa/table.hpp index f82586a5..1afcc7a2 100644 --- a/include/boost/unordered/detail/foa/table.hpp +++ b/include/boost/unordered/detail/foa/table.hpp @@ -133,22 +133,28 @@ private: template friend class table_erase_return_type; template friend class table; - table_iterator(group_type* pg,std::size_t n,const table_element_type* p_) + template< + typename Ptr,typename Ptr2, + typename std::enable_if::value>::type* = nullptr + > + static Ptr to_pointer(Ptr2 p) { - if(pg) - { - using pointer_traits=boost::pointer_traits; - pc=pointer_traits::pointer_to( - reinterpret_cast(const_cast(pg))[n]); - } - - if(p_) - { - using pointer_traits=boost::pointer_traits; - p=pointer_traits::pointer_to(*const_cast(p_)); - } + if(!p){return nullptr;} + return boost::pointer_traits::pointer_to(*p); } + template + static Ptr to_pointer(Ptr p) + { + return p; + } + + table_iterator(group_type* pg,std::size_t n,const table_element_type* p_): + pc{to_pointer( + reinterpret_cast(const_cast(pg))+n)}, + p{to_pointer(const_cast(p_))} + {} + inline void increment()noexcept { BOOST_ASSERT(p!=nullptr);