// Copyright (c) 2010-2011 CNRS and LIRIS' Establishments (France). // All rights reserved. // // 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; either version 3 of the License, // or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // 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) : Guillaume Damiand // #ifndef CGAL_INTERNAL_COMBINATORIAL_MAP_UTILITY_H #define CGAL_INTERNAL_COMBINATORIAL_MAP_UTILITY_H 1 #include #include #include #include #include /** Some utilities allowing to manage attributes. Indeed, as they as stores * in tuples, we need to define functors with variadic templated arguments * to deal with these attributes. * * The class Combinatorial_map_helper defines: * */ namespace CGAL { namespace internal { // There is a problem on windows to handle tuple containing void. // To solve this, we transform such a tuple in tuple containing Disabled. template struct Convert_void { typedef T type; }; template<> struct Convert_void { typedef CGAL::Void type; }; #if ! defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES) && \ ! defined(CGAL_CFG_NO_CPP0X_TUPLE) // Convert a tuple in a same tuple where each void type was replaced into // CGAL::Void. template struct Convert_tuple_with_void; template struct Convert_tuple_with_void > { typedef CGAL::cpp11::tuple::type... > type; }; // Length of a variadic template template struct My_length; template struct My_length > { static const int value = My_length >::value + 1; }; template<> struct My_length > { static const int value = 0; }; //count the number of time a given type is present in a tuple template struct Number_of_type_in_tuple; template struct Number_of_type_in_tuple >{ static const int value=Number_of_type_in_tuple >::value+1; }; template struct Number_of_type_in_tuple >{ static const int value=Number_of_type_in_tuple >::value; }; template struct Number_of_type_in_tuple >{ static const int value=0; }; //count the number of different types from Type is present in a tuple template struct Number_of_different_type_in_tuple; template struct Number_of_different_type_in_tuple > { static const int value=Number_of_different_type_in_tuple >::value+1; }; template struct Number_of_different_type_in_tuple > { static const int value=Number_of_different_type_in_tuple >::value; }; template struct Number_of_different_type_in_tuple > { static const int value=0; }; //count the number of time a given type have been found //within a tuple, until reaching position the k'th type of the tuple. //dim is the total size of the tuple template ::value-1> struct Nb_type_in_tuple_up_to_k; template struct Nb_type_in_tuple_up_to_k,dim> { static const int pos= Nb_type_in_tuple_up_to_k ,dim>::pos - 1; static const int value = ( pos==k ) ? ( boost::is_same::value ? 0:-dim-1 ) : ( ( pos::value ? 1:0 ) + Nb_type_in_tuple_up_to_k ,dim >::value) :0 ); }; template struct Nb_type_in_tuple_up_to_k,dim > { static const int pos=dim; static const int value=(pos==k? (boost::is_same::value?0:-dim-1) : 0); }; //count the number of time a type different from Type have been found //within a tuple, until reaching position the k'th type of the tuple. //dim is the total size of the tuple template ::value-1> struct Nb_type_different_in_tuple_up_to_k; template struct Nb_type_different_in_tuple_up_to_k,dim> { static const int pos = Nb_type_different_in_tuple_up_to_k ,dim >::pos - 1; static const int value = ( pos==k ) ? ( boost::is_same::value ? -dim-1 : 0 ) : ( ( pos::value ? 0:1 ) + Nb_type_different_in_tuple_up_to_k ,dim >::value) :0 ); }; template struct Nb_type_different_in_tuple_up_to_k,dim > { static const int pos=dim; static const int value=(pos==k? (boost::is_same::value?-dim-1:0) : 0); }; //Convert a tuple of T... to a tuple of Functor::type... template