Move is_iterator changes back to the original file.

This commit is contained in:
Marc Glisse 2013-07-19 21:55:34 +02:00
parent 95c6e3526d
commit dafdb45786
4 changed files with 25 additions and 64 deletions

View File

@ -22,6 +22,9 @@ concept: it is missing the constructions `Lift_to_paraboloid_d` and
`Project_along_d_axis_d` which do not make sense with a single fixed
dimension.
Only the interfaces specific to this class are listed here, refer to the
concepts for the rest.
\cgalModels `Kernel_d`
\cgalModels `DelaunayTriangulationTraits`

View File

@ -1,64 +0,0 @@
// Copyright (c) 2011 INRIA Saclay Ile-de-France (France).
// All rights reserved.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; version 2.1 of the License.
// See the file LICENSE.LGPL distributed with CGAL.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Marc Glisse
#ifndef CGAL_IS_ITERATOR_H
#define CGAL_IS_ITERATOR_H
#include <iterator>
#include <boost/type_traits.hpp>
#include <boost/mpl/has_xxx.hpp>
namespace CGAL {
namespace internal {
BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category)
template <class T> struct is_iterator_ {
enum { value = has_iterator_category<T>::value
|| boost::is_pointer<T>::value };
};
template <class T,class U,bool=is_iterator_<T>::value>
struct is_iterator_type_ {
enum { value=false };
};
template <class T,class U> struct is_iterator_type_<T,U,true> :
//boost::is_base_of<U,typename std::iterator_traits<T>::iterator_category>
boost::is_convertible<typename std::iterator_traits<T>::iterator_category,U>
{};
}
// NOTE: we don't want the real std::decay or functions are included
template <class T> struct is_iterator :
internal::is_iterator_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type> {};
template <class T,class Tg> struct is_iterator_type :
internal::is_iterator_type_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type,Tg> {};
template <class T,class U,bool=is_iterator<T>::value> struct is_iterator_to {
enum { value=false };
};
template <class T,class U> struct is_iterator_to<T,U,true> :
boost::is_convertible<typename std::iterator_traits<T>::value_type,U>
{ };
}
#endif // CGAL_IS_ITERATOR_H

View File

@ -67,6 +67,13 @@ template <class T> struct is_iterator :
template <class T,class Tag> struct is_iterator_type :
internal::is_iterator_type_<typename boost::remove_cv<typename boost::remove_reference<T>::type>::type,Tag> {};
template <class T,class U,bool=is_iterator<T>::value> struct is_iterator_to {
enum { value=false };
};
template <class T,class U> struct is_iterator_to<T,U,true> :
boost::is_convertible<typename std::iterator_traits<T>::value_type,U>
{ };
}
#endif // CGAL_IS_ITERATOR_H

View File

@ -2,14 +2,29 @@
#include <CGAL/assertions.h>
#include <CGAL/is_iterator.h>
#include <vector>
#include <list>
struct A { };
int main() {
typedef std::vector<int>::const_iterator vector_it;
typedef std::list<int>::const_iterator list_it;
typedef int* int_p;
using CGAL::is_iterator;
using CGAL::is_iterator_type;
using CGAL::is_iterator_to;
CGAL_static_assertion(is_iterator<vector_it>::value);
CGAL_static_assertion(is_iterator<list_it>::value);
CGAL_static_assertion(!is_iterator<void>::value);
CGAL_static_assertion(!is_iterator<int>::value);
CGAL_static_assertion(is_iterator<int_p>::value);
CGAL_static_assertion((is_iterator_type<vector_it,std::bidirectional_iterator_tag>::value));
CGAL_static_assertion((!is_iterator_type<list_it,std::random_access_iterator_tag>::value));
CGAL_static_assertion((!is_iterator_type<short,std::output_iterator_tag>::value));
CGAL_static_assertion((is_iterator_to<int_p,double>::value));
CGAL_static_assertion((!is_iterator_to<A,int>::value));
CGAL_static_assertion((!is_iterator_to<A*,int>::value));
}