mirror of https://github.com/CGAL/cgal
add non-documented remove_const fcts to turn a const-iterator to an iterator
This commit is contained in:
parent
55d9d30f26
commit
675d26e884
|
|
@ -164,6 +164,11 @@ namespace internal {
|
|||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
In_place_list_iterator<T,Alloc>
|
||||
remove_const() const
|
||||
{
|
||||
return In_place_list_iterator<T,Alloc>(const_cast<T*>(node));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@
|
|||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/type_traits/remove_pointer.hpp>
|
||||
|
||||
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<Ref>::type
|
||||
>::type&,
|
||||
typename boost::remove_const<
|
||||
typename boost::remove_pointer<Ptr>::type
|
||||
>::type* >
|
||||
remove_const() const
|
||||
{
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::remove_pointer<Ptr>::type
|
||||
>::type* Ptr_no_c;
|
||||
return vector_iterator< T,
|
||||
typename boost::remove_const<typename boost::remove_reference<Ref>::type>::type&,
|
||||
Ptr_no_c>
|
||||
( const_cast<Ptr_no_c>(ptr) );
|
||||
}
|
||||
};
|
||||
|
||||
template < class T, class Ref, class Ptr> inline
|
||||
|
|
|
|||
|
|
@ -888,6 +888,7 @@ void test_In_place_list() {
|
|||
{
|
||||
typedef CGAL::In_place_list<Cont,false> ContList;
|
||||
typedef CGAL::In_place_list<Cont,false>::iterator Iterator;
|
||||
typedef CGAL::In_place_list<Cont,false>::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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <CGAL/use.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue