/usr/include/CGAL/Coercion_traits.h is in libcgal-dev 4.11-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | // Copyright (c) 2006-2007 Max-Planck-Institute Saarbruecken (Germany).
// 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) : Michael Hemmer <hemmer@mpi-inf.mpg.de>
//
// =============================================================================
/*! \file NiX/Coercion_traits.h
* \brief Defines class NiX::Coercion_traits.
*
* Provides the general definition of the \c Coercion_traits<A,B> class, with
* specializations for the builtin number types.
*/
#ifndef CGAL_COERCION_TRAITS_H
#define CGAL_COERCION_TRAITS_H 1
#include <iterator>
#include <CGAL/boost/iterator/transform_iterator.hpp>
#include <boost/type_traits/is_same.hpp>
#include <CGAL/tags.h>
// Makro to define an additional operator for binary functors which takes
// two number types as parameters that are interoperable with the
// number type
#define CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( NT, Result_type ) \
template < class CT_Type_1, class CT_Type_2 > \
Result_type operator()( const CT_Type_1& x, const CT_Type_2& y ) const { \
CGAL_static_assertion((::boost::is_same< \
typename Coercion_traits< CT_Type_1, CT_Type_2 >::Type, NT \
>::value)); \
\
typename Coercion_traits< CT_Type_1, CT_Type_2 >::Cast cast; \
return operator()( cast(x), cast(y) ); \
}
#define CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( NT ) \
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( NT, NT )
#define CGAL_DEFINE_COERCION_TRAITS_FROM_TO(FROM,TO) \
template <> \
struct Coercion_traits< FROM , TO >{ \
typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \
typedef TO Type; \
struct Cast{ \
typedef Type result_type; \
Type operator()(const TO& x) const { return x;} \
Type operator()(const FROM& x) const { \
return Type(x);} \
}; \
}; \
template <> \
struct Coercion_traits< TO , FROM >{ \
typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \
typedef TO Type; \
struct Cast{ \
typedef Type result_type; \
Type operator()(const TO& x) const { return x;} \
Type operator()(const FROM& x) const { \
return Type(x);} \
}; \
};
#define CGAL_DEFINE_COERCION_TRAITS_FROM_TO_TEM(FROM,TO,TEM) \
template <TEM> \
struct Coercion_traits< FROM , TO >{ \
typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \
typedef TO Type; \
struct Cast{ \
typedef Type result_type; \
Type operator()(const TO& x) const { return x;} \
Type operator()(const FROM& x) const { \
return Type(x);} \
}; \
}; \
template <TEM> \
struct Coercion_traits< TO , FROM >{ \
typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \
typedef TO Type; \
struct Cast{ \
typedef Type result_type; \
Type operator()(const TO& x) const { return x;} \
Type operator()(const FROM& x) const { \
return Type(x);} \
}; \
};
#define CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(A) \
template <> \
struct Coercion_traits< A , A >{ \
typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \
typedef A Type; \
struct Cast{ \
typedef Type result_type; \
Type operator()(const A& x) const { return x;} \
}; \
};
#define CGAL_DEFINE_COERCION_TRAITS_FOR_SELF_TEM(A,TEM) \
template <TEM> \
struct Coercion_traits< A , A >{ \
typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \
typedef A Type; \
struct Cast{ \
typedef Type result_type; \
Type operator()(const A& x) const {return x;} \
}; \
};
namespace CGAL {
namespace INTERN_CT{
template< class FROM, class TO >struct Cast_from_to{
typedef TO result_type;
TO operator()(const TO& x) const {return x;}
TO operator()(const FROM& x) const {return TO(x);}
};
template< class TO>
struct Cast_from_to<TO,TO>{
typedef TO result_type;
TO operator()(const TO& x) const {return x;}
};
}
template<class A , class B> struct Coercion_traits;
template<class A , class B, int > struct Coercion_traits_for_level;
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short,int)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short,long)
#ifdef CGAL_USE_LONG_LONG
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short,long long)
#endif
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short,float)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short,double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short,long double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int,long)
#ifdef CGAL_USE_LONG_LONG
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int,long long)
#endif
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int,float)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int,double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int,long double)
#ifdef CGAL_USE_LONG_LONG
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long,long long)
#endif
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long,float)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long,double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long,long double)
#ifdef CGAL_USE_LONG_LONG
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long long,float)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long long,double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long long,long double)
#endif
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(float,double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(float,long double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(double,long double)
//! Specialization for equal types.
template <class A>
struct Coercion_traits<A,A>{
typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable;
typedef A Type;
struct Cast{
typedef Type result_type;
Type inline operator()(const A& x) const {
return x;
}
};
};
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(short)
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(int)
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(long)
#ifdef CGAL_USE_LONG_LONG
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(long long)
#endif
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(float)
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(double)
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(long double)
enum COERCION_TRAITS_LEVEL {
CTL_TOP = 4,
CTL_POLYNOMIAL = 4,
CTL_COMPLEX = 3,
CTL_INTERVAL = 2,
CTL_SQRT_EXT = 1
};
template <class A, class B, int i >
struct Coercion_traits_for_level: public Coercion_traits_for_level<A,B,i-1>{};
template <class A, class B>
struct Coercion_traits_for_level<A,B,0> {
typedef Tag_false Are_explicit_interoperable;
typedef Tag_false Are_implicit_interoperable;
// typedef Null_type Type;
typedef Null_functor Cast;
};
template<class A , class B>
struct Coercion_traits :public Coercion_traits_for_level<A,B,CTL_TOP>{};
} //namespace CGAL
#endif //NiX_COERCION_TRAITS_H
|