// Copyright (c) 2010-2011 CNRS and LIRIS' Establishments (France). // All rights reserved. // // This file is part of CGAL (www.cgal.org) // // $URL: https://github.com/CGAL/cgal/blob/v5.2/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h $ // $Id: Combinatorial_map_utility.h 52164b1 2019-10-19T15:34:59+02:00 Sébastien Loriot // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Guillaume Damiand // #ifndef CGAL_INTERNAL_COMBINATORIAL_MAP_UTILITY_H #define CGAL_INTERNAL_COMBINATORIAL_MAP_UTILITY_H 1 #include #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 Void. template struct Convert_void { typedef T type; }; template<> struct Convert_void { typedef CGAL::Void type; }; // Get the type Dart_info defined as inner type of T. // If T::Dart_info is not defined or if T::Dart_info is void, defined // CGAL::Void as type. BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_dart_info,Dart_info,false) template::value > struct Get_dart_info { typedef CGAL::Void type; }; template struct Get_dart_info { typedef typename Convert_void::type type; }; // Get the type Darts_with_id as inner type of T. // If T::Darts_with_id is not defined or if T::Darts_widh_id is Tag_false BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_darts_with_id,Darts_with_id,false) template::value > struct Get_darts_with_id { typedef CGAL::Tag_false type; }; template struct Get_darts_with_id { typedef CGAL::Tag_true type; }; // Get the type Attributes defined as inner type of T. // If T::Attributes is not defined, defined std::tuple<> as type. BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_attributes_tuple,Attributes,false) template::value > struct Get_attributes_tuple { typedef std::tuple<> type; }; template struct Get_attributes_tuple { typedef typename T::Attributes type; }; // 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 std::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