diff --git a/STL_Extension/include/CGAL/In_place_list.h b/STL_Extension/include/CGAL/In_place_list.h index 9c99f2e9a8f..1d65f4ace94 100644 --- a/STL_Extension/include/CGAL/In_place_list.h +++ b/STL_Extension/include/CGAL/In_place_list.h @@ -27,7 +27,6 @@ #include #include #include -#include namespace CGAL { @@ -175,7 +174,6 @@ namespace internal { }; - template std::size_t hash_value(const In_place_list_iterator& i) { @@ -189,7 +187,7 @@ template { const T* ptr = i.operator->(); return reinterpret_cast(ptr)/ sizeof(T); - } + } } @@ -792,8 +790,7 @@ namespace std { std::size_t operator()(const CGAL::internal::In_place_list_iterator& i) const { - const T* ptr = i.operator->(); - return reinterpret_cast(ptr)/ sizeof(T); + return CGAL::internal::hash_value(i); } }; @@ -803,8 +800,7 @@ namespace std { std::size_t operator()(const CGAL::internal::In_place_list_const_iterator& i) const { - const T* ptr =i.operator->(); - return reinterpret_cast(ptr)/ sizeof(T); + return CGAL::internal::hash_value(i); } }; #endif // CGAL_CFG_NO_STD_HASH diff --git a/STL_Extension/include/CGAL/vector.h b/STL_Extension/include/CGAL/vector.h index c10a8fdd53a..192baedacdc 100644 --- a/STL_Extension/include/CGAL/vector.h +++ b/STL_Extension/include/CGAL/vector.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -135,6 +136,13 @@ public: } }; +template < class T, class Ref, class Ptr> +std::size_t hash_value(const vector_iterator& i) +{ + Ptr ptr = i.operator->(); + return reinterpret_cast(ptr)/ sizeof(T); +} + template < class T, class Ref, class Ptr> inline vector_iterator operator+( std::ptrdiff_t n, vector_iterator i) { @@ -609,4 +617,31 @@ void vector::insert( iterator position, size_type n, const T& x) { } //namespace CGAL +namespace std { + +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable:4099) // For VC10 it is class hash +#endif + +#ifndef CGAL_CFG_NO_STD_HASH + + template < class T, class Ref, class Ptr> + struct hash > + : public CGAL::cpp98::unary_function, std::size_t> { + + std::size_t operator()(const CGAL::internal::vector_iterator& i) const + { + return CGAL::internal::hash_value(i); + } + }; + +#endif // CGAL_CFG_NO_STD_HASH + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#endif + +} // namespace std + #endif // CGAL_VECTOR_H //