diff --git a/STL_Extension/include/CGAL/In_place_list.h b/STL_Extension/include/CGAL/In_place_list.h index ecdf77e06b9..e0e54588535 100644 --- a/STL_Extension/include/CGAL/In_place_list.h +++ b/STL_Extension/include/CGAL/In_place_list.h @@ -164,6 +164,11 @@ namespace internal { --*this; return tmp; } + In_place_list_iterator + remove_const() const + { + return In_place_list_iterator(const_cast(node)); + } }; } diff --git a/STL_Extension/include/CGAL/vector.h b/STL_Extension/include/CGAL/vector.h index 0329fa54046..8be7fde982c 100644 --- a/STL_Extension/include/CGAL/vector.h +++ b/STL_Extension/include/CGAL/vector.h @@ -32,6 +32,9 @@ #include #include #include +#include +#include +#include namespace CGAL { @@ -118,6 +121,24 @@ public: bool operator> ( const Self& i) const { return i < *this; } bool operator<=( const Self& i) const { return !(i < *this); } bool operator>=( const Self& i) const { return !(*this < i); } + + vector_iterator< T, + typename boost::remove_const< + typename boost::remove_reference::type + >::type&, + typename boost::remove_const< + typename boost::remove_pointer::type + >::type* > + remove_const() const + { + typedef typename boost::remove_const< + typename boost::remove_pointer::type + >::type* Ptr_no_c; + return vector_iterator< T, + typename boost::remove_const::type>::type&, + Ptr_no_c> + ( const_cast(ptr) ); + } }; template < class T, class Ref, class Ptr> inline diff --git a/STL_Extension/test/STL_Extension/test_In_place_list.cpp b/STL_Extension/test/STL_Extension/test_In_place_list.cpp index 5a31a88d0ae..76889732388 100644 --- a/STL_Extension/test/STL_Extension/test_In_place_list.cpp +++ b/STL_Extension/test/STL_Extension/test_In_place_list.cpp @@ -888,6 +888,7 @@ void test_In_place_list() { { typedef CGAL::In_place_list ContList; typedef CGAL::In_place_list::iterator Iterator; + typedef CGAL::In_place_list::const_iterator Const_iterator; ContList L; L.push_back(* new Cont(3)); @@ -901,7 +902,14 @@ void test_In_place_list() { for (++it2; it2 != L.end(); it1=it2, ++it2) { assert( (*it1).i_ <= (*it2).i_ ); } - + + // test remove_const + Const_iterator cit=L.begin(); + Iterator it=cit.remove_const(); + + CGAL_USE(cit); + CGAL_USE(it); + L.destroy(); } diff --git a/STL_Extension/test/STL_Extension/test_vector.cpp b/STL_Extension/test/STL_Extension/test_vector.cpp index c075cf74919..340d8522d48 100644 --- a/STL_Extension/test/STL_Extension/test_vector.cpp +++ b/STL_Extension/test/STL_Extension/test_vector.cpp @@ -33,6 +33,7 @@ #include #include #include +#include class X { public: @@ -212,6 +213,14 @@ int main() { assert( V7[1] == X(9)); assert( V7.size() == 16); std::cout << "done" << std::endl; - + + // test remove_const + const_iterator mycit=V3.begin(); + iterator myit=cit.remove_const(); + iterator myit2=myit.remove_const(); + CGAL_USE(mycit); + CGAL_USE(myit); + CGAL_USE(myit2); + return 0; }