Merge pull request #5904 from sloriot/CGAL-remove_config_flags

Replace macros with inline functions and remove a config flag
This commit is contained in:
Sebastien Loriot 2021-09-10 17:38:50 +02:00 committed by GitHub
commit 4610cf3c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 91 additions and 418 deletions

View File

@ -148,33 +148,26 @@ 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,long long)
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,long long)
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,long long)
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(long long,float)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long long,double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long long,long double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(float,double)
CGAL_DEFINE_COERCION_TRAITS_FROM_TO(float,long double)
@ -198,9 +191,7 @@ struct Coercion_traits<A,A>{
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(long long)
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(float)
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(double)
CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(long double)

View File

@ -75,11 +75,9 @@ template <> struct Needs_parens_as_product<long>{
bool operator()(const long& x){return x < long(0);}
};
#ifdef CGAL_USE_LONG_LONG
template <> struct Needs_parens_as_product<long long>{
bool operator()(const long long& x){return x < (long long)(0);}
};
#endif
template <> struct Needs_parens_as_product<float>{
bool operator()(const float& x){return x < float(0);}

View File

@ -169,19 +169,15 @@ overlay(const Arrangement_on_surface_2<GeometryTraitsA_2, TopologyTraitsA>& arr1
typedef typename Arr_res::Allocator Allocator;
// some type assertions (not all, but better than nothing).
#if !defined(CGAL_NO_ASSERTIONS)
typedef typename Agt2::Point_2 A_point;
typedef typename Bgt2::Point_2 B_point;
typedef typename Rgt2::Point_2 Res_point;
#endif
CGAL_static_assertion((boost::is_convertible<A_point, Res_point>::value));
CGAL_static_assertion((boost::is_convertible<B_point, Res_point>::value));
#if !defined(CGAL_NO_ASSERTIONS)
typedef typename Agt2::X_monotone_curve_2 A_xcv;
typedef typename Bgt2::X_monotone_curve_2 B_xcv;
typedef typename Rgt2::X_monotone_curve_2 Res_xcv;
#endif
CGAL_static_assertion((boost::is_convertible<A_xcv, Res_xcv>::value));
CGAL_static_assertion((boost::is_convertible<B_xcv, Res_xcv>::value));

View File

@ -382,9 +382,7 @@ If GLPK is not automatically found, the following variables must be set:
A number of boolean flags are used to workaround compiler bugs and
limitations. They all start with the prefix `CGAL_CFG`. These
flags are used to work around compiler bugs and limitations. For
example, the flag `CGAL_CFG_NO_CPP0X_LONG_LONG` denotes
that the compiler does not know the type `long long`.
flags are used to work around compiler bugs and limitations.
For each installation a file <TT><CGAL/compiler_config.h></TT>
is defined, with the correct

View File

@ -17,34 +17,21 @@
#ifdef CGAL_HAS_THREADS
# ifdef CGAL_CAN_USE_CXX11_ATOMIC
# include <atomic>
# define CGAL_ATOMIC_NS std
# else // not CGAL_CAN_USE_CXX11_ATOMIC
# if BOOST_VERSION >= 105300
# include <boost/atomic.hpp>
# define CGAL_ATOMIC_NS boost
# else // BOOST_VERSION < 105300
# define CGAL_NO_ATOMIC "Boost.Atomic was introduced in Boost-1.53".
# endif // BOOST_VERSION < 105300
# endif // not CGAL_CAN_USE_CXX11_ATOMIC
# ifndef CGAL_NO_ATOMIC
namespace CGAL {
namespace cpp11 {
using CGAL_ATOMIC_NS ::atomic;
namespace CGAL {
namespace cpp11 {
using std::atomic;
using CGAL_ATOMIC_NS ::memory_order_relaxed;
using CGAL_ATOMIC_NS ::memory_order_consume;
using CGAL_ATOMIC_NS ::memory_order_acquire;
using CGAL_ATOMIC_NS ::memory_order_release;
using CGAL_ATOMIC_NS ::memory_order_acq_rel;
using CGAL_ATOMIC_NS ::memory_order_seq_cst;
using std::memory_order_relaxed;
using std::memory_order_consume;
using std::memory_order_acquire;
using std::memory_order_release;
using std::memory_order_acq_rel;
using std::memory_order_seq_cst;
using CGAL_ATOMIC_NS ::atomic_thread_fence;
}
}
# endif // CGAL_ATOMIC_NS
using std::atomic_thread_fence;
} }
#else
# define CGAL_NO_ATOMIC "No atomic because CGAL_NO_THREADS is defined."
#endif // CGAL_HAS_THREADS

View File

@ -127,16 +127,6 @@
#include <boost/config.hpp>
#include <boost/version.hpp>
// Hack: Boost<1.55 does not detect correctly the C++11 features of ICC.
// We declare by hand two features that we need (variadic templates and
// rvalue references).
#if defined(__INTEL_COMPILER) && defined(__GXX_EXPERIMENTAL_CXX0X__)
# undef BOOST_NO_VARIADIC_TEMPLATES
# undef BOOST_NO_CXX11_VARIADIC_TEMPLATES
# undef BOOST_NO_RVALUE_REFERENCES
# undef BOOST_NO_CXX11_RVALUE_REFERENCES
#endif
#include <CGAL/version.h>
//----------------------------------------------------------------------//
@ -167,98 +157,6 @@
#define CGAL_USE_SSE2_FABS
#endif
//----------------------------------------------------------------------//
// Detect features at compile-time. Some macros have only been
// introduced as of Boost 1.40. In that case, we simply say that the
// feature is not available, even if that is wrong.
// ----------------------------------------------------------------------//
#if defined(BOOST_NO_0X_HDR_ARRAY)
#define CGAL_CFG_NO_CPP0X_ARRAY 1
#endif
#if defined(BOOST_NO_0X_HDR_UNORDERED_SET) || \
defined(BOOST_NO_0X_HDR_UNORDERED_MAP) || \
(defined(_MSC_VER) && (_MSC_VER == 1800)) // std::unordered_set is very bad in MSVC2013
#define CGAL_CFG_NO_CPP0X_UNORDERED 1
#endif
#if defined( BOOST_NO_0X_HDR_THREAD)
#define CGAL_CFG_NO_STD_THREAD 1
#endif
#if defined(BOOST_NO_DECLTYPE)
#define CGAL_CFG_NO_CPP0X_DECLTYPE 1
#endif
#if defined(BOOST_NO_DELETED_FUNCTIONS) || \
defined(BOOST_NO_DEFAULTED_FUNCTIONS) || \
(defined(_MSC_VER) && _MSC_VER < 1900) // MSVC 2013 has only partial support
#define CGAL_CFG_NO_CPP0X_DELETED_AND_DEFAULT_FUNCTIONS 1
#endif
#if defined(BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS)
#define CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES 1
#endif
#if defined(BOOST_NO_INITIALIZER_LISTS)
#define CGAL_CFG_NO_CPP0X_INITIALIZER_LISTS 1
#endif
#if defined(BOOST_MSVC)
#define CGAL_CFG_NO_CPP0X_ISFINITE 1 // used in <CGAL/CORE/Filter.h>
#endif
#if defined(BOOST_NO_LONG_LONG)
#define CGAL_CFG_NO_CPP0X_LONG_LONG 1
#endif
#if defined(BOOST_NO_LAMBDAS)
#define CGAL_CFG_NO_CPP0X_LAMBDAS 1
#endif
#if defined(BOOST_NO_RVALUE_REFERENCES)
#define CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE 1
#endif
#if defined(BOOST_NO_STATIC_ASSERT)
#define CGAL_CFG_NO_CPP0X_STATIC_ASSERT 1
#endif
#if defined(BOOST_NO_0X_HDR_TUPLE)
#define CGAL_CFG_NO_CPP0X_TUPLE 1
#endif
#if defined(BOOST_NO_VARIADIC_TEMPLATES)
#define CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES 1
#endif
// never use TR1
#define CGAL_CFG_NO_TR1_ARRAY 1
// never use TR1
#define CGAL_CFG_NO_TR1_TUPLE 1
#if (__GNUC__ <= 0) || defined(__INTEL_COMPILER)
#define CGAL_CFG_NO_STATEMENT_EXPRESSIONS 1
#endif
#if _MSC_VER==1800
#define CGAL_CFG_NO_CPP0X_UNIFIED_INITIALIZATION_SYNTAX
#endif
#if __cplusplus < 201103L && !(_MSC_VER >= 1600)
#define CGAL_CFG_NO_CPP0X_COPY_N 1
#define CGAL_CFG_NO_CPP0X_NEXT_PREV 1
#endif
#if defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATIONS) \
|| defined(BOOST_NO_EXPLICIT_CONVERSION_OPERATORS)
#define CGAL_CFG_NO_CPP0X_EXPLICIT_CONVERSION_OPERATORS 1
#endif
#if defined(BOOST_NO_TEMPLATE_ALIASES)
#define CGAL_CFG_NO_CPP0X_TEMPLATE_ALIASES 1
#endif
// Some random list to let us write C++11 without thinking about
// each feature we are using.
#if ( __cplusplus >= 201103L || _MSVC_LANG >= 201103L ) && \
!defined CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES && \
!defined CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE && \
!defined CGAL_CFG_NO_CPP0X_EXPLICIT_CONVERSION_OPERATORS && \
!defined CGAL_CFG_NO_CPP0X_TUPLE && \
!defined CGAL_CFG_NO_CPP0X_UNIFIED_INITIALIZATION_SYNTAX && \
!defined CGAL_CFG_NO_CPP0X_STATIC_ASSERT && \
!defined CGAL_CFG_NO_CPP0X_DECLTYPE && \
!defined CGAL_CFG_NO_CPP0X_DELETED_AND_DEFAULT_FUNCTIONS && \
!defined CGAL_CFG_NO_CPP0X_DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATES
#define CGAL_CXX11 1
#endif
// Same for C++14.
#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L
# define CGAL_CXX14 1
#endif
// Same for C++17
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
# define CGAL_CXX17 1
@ -300,28 +198,12 @@
#define CGAL_END_NAMESPACE }
#endif
#ifndef CGAL_CFG_NO_CPP0X_LONG_LONG
# define CGAL_USE_LONG_LONG
#endif
#ifndef CGAL_CFG_TYPENAME_BEFORE_DEFAULT_ARGUMENT_BUG
# define CGAL_TYPENAME_DEFAULT_ARG typename
#else
# define CGAL_TYPENAME_DEFAULT_ARG
#endif
#ifdef CGAL_CFG_NO_CPP0X_DELETED_AND_DEFAULT_FUNCTIONS
# define CGAL_DELETED
# define CGAL_EXPLICITLY_DEFAULTED
#else
# define CGAL_DELETED = delete
# define CGAL_EXPLICITLY_DEFAULTED = default
#endif
// Big endian or little endian machine.
// ====================================
@ -481,7 +363,7 @@ using std::max;
#define CGAL_NORETURN [[noreturn]]
// Macro to specify [[no_unique_address]] if supported
#if CGAL_CXX11 && __has_cpp_attribute(no_unique_address)
#if __has_cpp_attribute(no_unique_address)
# define CGAL_NO_UNIQUE_ADDRESS [[no_unique_address]]
#else
# define CGAL_NO_UNIQUE_ADDRESS
@ -508,25 +390,6 @@ using std::max;
# endif
#endif
#if __has_feature(cxx_thread_local) || \
( (__GNUC__ > 0) && __cplusplus >= 201103L ) || \
( _MSC_VER >= 1900 )
// see also Installation/cmake/modules/config/support/CGAL_test_cpp_version.cpp
#define CGAL_CAN_USE_CXX11_THREAD_LOCAL
#endif
#if (__has_include(<mutex>) && __cplusplus >= 201103L ) | \
( (__GNUC__ > 0) && __cplusplus >= 201103L ) || \
( _MSC_VER >= 1700 )
#define CGAL_CAN_USE_CXX11_MUTEX
#endif
#if (__has_include(<atomic>) && __cplusplus >= 201103L ) || \
( (__GNUC__ > 0) && __cplusplus >= 201103L ) || \
( _MSC_VER >= 1700 )
#define CGAL_CAN_USE_CXX11_ATOMIC
#endif
#ifndef CGAL_HAS_THREADS
namespace CGAL { inline bool is_currently_single_threaded(){ return true; } }
#elif __has_include(<sys/single_threaded.h>)

View File

@ -13,14 +13,8 @@
#include <CGAL/config.h>
#ifdef CGAL_HAS_THREADS
#ifdef CGAL_CAN_USE_CXX11_MUTEX
#include <mutex>
#define CGAL_MUTEX std::mutex
#define CGAL_SCOPED_LOCK(M) std::unique_lock<std::mutex> scoped_lock(M)
#else
#include <boost/thread/mutex.hpp>
#define CGAL_MUTEX boost::mutex
#define CGAL_SCOPED_LOCK(M) boost::mutex::scoped_lock scoped_lock(M)
#endif
#endif
#endif // CGAL_MUTEX_H

View File

@ -105,14 +105,7 @@ const int TET_SHAPE = 3;
# define CGAL_CONCURRENT_MESH_3_PROFILING
//# define CGAL_DEBUG_FORCE_SEQUENTIAL_MESH_REFINEMENT
// ==========================================================================
// TBB
// ==========================================================================
# if TBB_IMPLEMENT_CPP0X
# include <tbb/compat/thread>
# else
# include <thread>
# endif
#include <thread>
// ==========================================================================
// SEQUENTIAL

View File

@ -126,6 +126,7 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
CGAL_FUNCTOR_INIT_STORE(Construct_cartesian_const_iterator_d)
typedef typename Get_functor<Base, Construct_ttag<Point_cartesian_const_iterator_tag> >::type CPI;
typedef typename Get_functor<Base, Construct_ttag<Vector_cartesian_const_iterator_tag> >::type CVI;
// @mglisse shall we update that code ?
// FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. Relying on CPI::result_type is great for Epick_d but not Epeck_d.
// typedef typename CGAL::decay<typename boost::result_of<CPI(Point_d,CGAL::Begin_tag)>::type>::type result_type;
// typedef typename CGAL::decay<typename CPI::result_type>::type result_type;

View File

@ -56,6 +56,7 @@ template<class T> struct Is_wrapper_iterator<T,true> :
{ };
struct Forward_rep {
//@mglisse shall we update that code?
//TODO: make a good C++0X version with perfect forwarding
//#ifdef CGAL_CXX11
//template <class T,class=typename std::enable_if<!Is_wrapper<typename std::decay<T>::type>::value&&!Is_wrapper_iterator<typename std::decay<T>::type>::value>::type>

View File

@ -112,16 +112,9 @@
#if !defined(CGAL_HAS_THREADS)
#define CGAL_MPZF_THREAD_LOCAL
#define CGAL_MPZF_TLS
#elif defined(CGAL_CAN_USE_CXX11_THREAD_LOCAL)
#else
#define CGAL_MPZF_THREAD_LOCAL thread_local
#define CGAL_MPZF_TLS thread_local
#elif defined(_MSC_VER)
#define CGAL_MPZF_THREAD_LOCAL __declspec(thread)
#define CGAL_MPZF_TLS
#else
#define CGAL_MPZF_THREAD_LOCAL __thread
#define CGAL_MPZF_TLS
// Too bad for the others
#endif
namespace CGAL {
namespace Mpzf_impl {
@ -162,7 +155,6 @@ template <class T, class = void> struct pool2 {
static T& ptr(T t) { t -= extra+1; return *reinterpret_cast<T*>(t); }
};
#if defined(CGAL_CAN_USE_CXX11_THREAD_LOCAL)
template <class T, class = void> struct pool3 {
static T pop() { T ret = data(); data() = ptr(data()); return ret; }
static void push(T t) { ptr(t) = data(); data() = t; }
@ -185,7 +177,6 @@ template <class T, class = void> struct pool3 {
}
static T& ptr(T t) { t -= extra+1; return *reinterpret_cast<T*>(t); }
};
#endif
// No caching
template <class T, class = void> struct no_pool {

View File

@ -54,11 +54,7 @@
#include <CGAL/Interval_nt.h> // needed by To_interval(long double), To_interval(long), To_interval(long long)
#include <CGAL/int.h>
#ifdef CGAL_USE_LONG_LONG
#include <CGAL/long_long.h>
#endif
#ifdef CGAL_USE_GMP
#ifdef CGAL_USE_GMPXX

View File

@ -96,10 +96,9 @@ void test_lazy_exact_nt() {
{ // see also Coercion_traits_test.C
#ifdef CGAL_USE_LEDA
#ifdef CGAL_USE_CORE
CGAL_assertion_code(typedef CGAL::Lazy_exact_nt<leda_integer> T1;)
CGAL_assertion_code(typedef CGAL::Lazy_exact_nt<CORE::Expr> T2;)
typedef CGAL::Lazy_exact_nt<leda_integer> T1;
typedef CGAL::Lazy_exact_nt<CORE::Expr> T2;
typedef CGAL::Coercion_traits<T1, T2> CT;
CGAL_USE_TYPE(CT);
CGAL_static_assertion((boost::is_same< typename CT::Are_implicit_interoperable,CGAL::Tag_false>::value));
CGAL_static_assertion((boost::is_same< typename CT::Are_explicit_interoperable,CGAL::Tag_false>::value));
#endif

View File

@ -30,9 +30,7 @@
#include <CGAL/leda_real.h>
#endif // CGAL_USE_LEDA
#ifdef CGAL_USE_LONG_LONG
# include <CGAL/long_long.h>
#endif
#include <CGAL/long_long.h>
#include <CGAL/Number_type_checker.h>
#include <cassert>
@ -77,10 +75,8 @@ int main()
// test_it<unsigned int>("unsigned int");
// test_it<unsigned long int>("unsigned long int");
// test_it<unsigned short int>("unsigned short int");
#ifdef CGAL_USE_LONG_LONG
test_it<long long>("long long");
// test_it<unsigned long long>("unsigned long long");
#endif
test_it<float>("float");
test_it<double>("double");
test_it<long double>("long double");

View File

@ -16,8 +16,6 @@ int main(){
(void)CGAL::compare(a,a);
unsigned long b = 42;
(void)CGAL::compare(b,b);
#ifdef CGAL_USE_LONG_LONG
unsigned long long c = 42;
(void)CGAL::compare(c,c);
#endif
}

View File

@ -32,9 +32,7 @@
#include <CGAL/leda_real.h>
#endif // CGAL_USE_LEDA
#ifdef CGAL_USE_LONG_LONG
# include <CGAL/long_long.h>
#endif
#include <CGAL/long_long.h>
#include <CGAL/Number_type_checker.h>
@ -63,10 +61,8 @@ int main()
// TESTIT(unsigned int, "unsigned int")
// TESTIT(unsigned long int, "unsigned long int")
// TESTIT(unsigned short int, "unsigned short int")
#ifdef CGAL_USE_LONG_LONG
TESTIT(long long, "long long")
// TESTIT(unsigned long long, "unsigned long long")
#endif
TESTIT(float, "float")
TESTIT(double, "double")
TESTIT(long double, "long double")

View File

@ -10,10 +10,6 @@
// Author(s) : Aymeric PELLE <aymeric.pelle@sophia.inria.fr>
// Mael Rouxel-Labbé
#if (__GNUC__>4) || (__GNUC__ == 4 && __GNUC_MINOR__ >=6)
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#include <CGAL/Periodic_3_regular_triangulation_traits_3.h>
#include <CGAL/use.h>

View File

@ -11,10 +11,6 @@
// Author(s) : Mariette Yvinec <Mariette.Yvinec@sophia.inria.fr>
// Manuel Caroli <Manuel.Caroli@sophia.inria.fr>
#if (__GNUC__>4) || (__GNUC__ == 4 && __GNUC_MINOR__ >=6)
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#include <CGAL/use.h>
template <class Traits>

View File

@ -246,11 +246,7 @@ public:
{
// handle vpm
typedef typename CGAL::GetVertexPointMap<TriangleMesh, NamedParameters>::const_type Local_vpm;
CGAL_USE_TYPE(Local_vpm);
CGAL_assertion_code(
static const bool same_vpm = (boost::is_same<Local_vpm,Vpm>::value); )
CGAL_static_assertion(same_vpm);
CGAL_static_assertion( (boost::is_same<Local_vpm,Vpm>::value) );
Vpm vpm =
parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point),
@ -562,11 +558,7 @@ public:
parameters::get_parameter(np, internal_np::apply_per_connected_component), true);
typedef typename CGAL::GetVertexPointMap<TriangleMesh, NamedParameters>::const_type Local_vpm;
CGAL_USE_TYPE(Local_vpm);
CGAL_assertion_code(
static const bool same_vpm = (boost::is_same<Local_vpm,Vpm>::value); )
CGAL_static_assertion(same_vpm);
CGAL_static_assertion((boost::is_same<Local_vpm,Vpm>::value));
Vpm vpm =
parameters::choose_parameter(parameters::get_parameter(np, internal_np::vertex_point),

View File

@ -620,7 +620,7 @@ struct Locate_with_AABB_tree_Tester<K, VPM, 3> // 3D
typedef CGAL::AABB_face_graph_triangle_primitive<G, VPM> AABB_face_graph_primitive;
typedef CGAL::AABB_traits<K, AABB_face_graph_primitive> AABB_face_graph_traits;
CGAL_assertion_code(typedef typename K::Point_3 Point_3;)
typedef typename K::Point_3 Point_3;
CGAL_static_assertion((std::is_same<typename AABB_face_graph_traits::Point_3, Point_3>::value));
CGAL::AABB_tree<AABB_face_graph_traits> tree_a;

View File

@ -1800,28 +1800,25 @@ void test_rebind(const PT& /*traits*/){
typedef typename PT::Innermost_coefficient_type IC;
{
CGAL_assertion_code( const int dimension = 1; );
typedef typename PT:: template Rebind<IC,1>::Other PT_IC_1;
CGAL_USE_TYPE(PT_IC_1);
CGAL_static_assertion((boost::is_same< typename PT_IC_1::Innermost_coefficient_type,
IC>::value));
CGAL_static_assertion((PT_IC_1::d==dimension));
CGAL_static_assertion((PT_IC_1::d==1));
}
{
CGAL_assertion_code( const int dimension = 2; );
typedef typename PT:: template Rebind<IC,2>::Other PT_IC_2;
CGAL_USE_TYPE(PT_IC_2);
CGAL_static_assertion((boost::is_same< typename PT_IC_2::Innermost_coefficient_type,
IC>::value));
CGAL_static_assertion((PT_IC_2::d==dimension));
CGAL_static_assertion((PT_IC_2::d==2));
}
{
CGAL_assertion_code( const int dimension = 3; )
typedef typename PT:: template Rebind<IC,3>::Other PT_IC_3;
CGAL_USE_TYPE(PT_IC_3);
CGAL_static_assertion((boost::is_same< typename PT_IC_3::Innermost_coefficient_type,
IC>::value));
CGAL_static_assertion((PT_IC_3::d==dimension));
CGAL_static_assertion((PT_IC_3::d==3));
}
{
typedef typename PT:: template Rebind<IC,1>::Other PT_IC_1;
@ -1831,8 +1828,8 @@ void test_rebind(const PT& /*traits*/){
CGAL_USE_TYPE(PT_IC_1);
CGAL_USE_TYPE(PT_IC_2);
CGAL_USE_TYPE(PT_IC_3);
CGAL_assertion_code(typedef typename PT_IC_1::Polynomial_d Poly1;)
CGAL_assertion_code(typedef typename PT_IC_2::Polynomial_d Poly2;)
typedef typename PT_IC_1::Polynomial_d Poly1;
typedef typename PT_IC_2::Polynomial_d Poly2;
CGAL_static_assertion((boost::is_same< typename PT_IC_1::Coefficient_type,
IC>::value));
@ -1866,7 +1863,6 @@ void test_rebind(const PT& /*traits*/){
typedef CGAL::CORE_arithmetic_kernel AT;
typedef typename AT::Integer Integer;
typedef typename AT::Rational Rational;
CGAL_assertion_code( const int dimension = 4; )
typedef typename PT:: template Rebind<Integer,4>::Other PT_Integer_4;
typedef typename PT:: template Rebind<Rational,4>::Other PT_Rational_4;
CGAL_USE_TYPE(PT_Integer_4);
@ -1875,12 +1871,11 @@ void test_rebind(const PT& /*traits*/){
Integer>::value));
CGAL_static_assertion((boost::is_same< typename PT_Rational_4::Innermost_coefficient_type,
Rational>::value));
CGAL_static_assertion((PT_Integer_4::d==dimension));
CGAL_static_assertion((PT_Rational_4::d==dimension));
CGAL_static_assertion((PT_Integer_4::d==4));
CGAL_static_assertion((PT_Rational_4::d==4));
}
#endif
{
CGAL_assertion_code( const int dimension = 4; )
typedef typename PT:: template Rebind<int,4>::Other PT_Integer_4;
typedef typename PT:: template Rebind<double,4>::Other PT_Rational_4;
CGAL_USE_TYPE(PT_Integer_4);
@ -1889,8 +1884,8 @@ void test_rebind(const PT& /*traits*/){
int>::value));
CGAL_static_assertion((boost::is_same< typename PT_Rational_4::Innermost_coefficient_type,
double>::value));
CGAL_static_assertion((PT_Integer_4::d==dimension));
CGAL_static_assertion((PT_Rational_4::d==dimension));
CGAL_static_assertion((PT_Integer_4::d==4));
CGAL_static_assertion((PT_Rational_4::d==4));
}
}

View File

@ -6,23 +6,20 @@
#include <CGAL/assertions.h>
int main(){
CGAL_assertion_code(typedef CGAL::Polynomial<int> Poly_int_1;)
CGAL_assertion_code(typedef CGAL::Polynomial<Poly_int_1> Poly_int_2;)
CGAL_assertion_code(typedef CGAL::Polynomial<Poly_int_2> Poly_int_3;)
typedef CGAL::Polynomial<int> Poly_int_1;
typedef CGAL::Polynomial<Poly_int_1> Poly_int_2;
typedef CGAL::Polynomial<Poly_int_2> Poly_int_3;
{
typedef CGAL::Polynomial_type_generator<int,1>::Type Polynomial;
CGAL_USE_TYPE(Polynomial);
CGAL_static_assertion((::boost::is_same<Polynomial, Poly_int_1>::value));
}
{
typedef CGAL::Polynomial_type_generator<int,2>::Type Polynomial;
CGAL_USE_TYPE(Polynomial);
CGAL_static_assertion((::boost::is_same<Polynomial, Poly_int_2>::value));
}
{
typedef CGAL::Polynomial_type_generator<int,3>::Type Polynomial;
CGAL_USE_TYPE(Polynomial);
CGAL_static_assertion((::boost::is_same<Polynomial, Poly_int_3>::value));
}
}

View File

@ -33,7 +33,7 @@ template <class NT , class RT>
inline
void convert_to(const NT& x, RT& r){
typedef CGAL::Coercion_traits<NT,RT> CT;
CGAL_assertion_code(typedef typename CT::Coercion_type RET;)
typedef typename CT::Coercion_type RET;
CGAL_static_assertion((::boost::is_same<RET,RT>::value));
r = typename CT::Cast()(x);
}
@ -878,7 +878,7 @@ void test_scalar_factor_traits(){
typedef CGAL::Polynomial<Integer> Polynomial;
typedef CGAL::Scalar_factor_traits<Polynomial> SFT;
typedef typename AT::Integer Scalar;
CGAL_assertion_code(typedef typename SFT::Scalar Scalar_;)
typedef typename SFT::Scalar Scalar_;
CGAL_static_assertion((::boost::is_same<Scalar_, Scalar>::value));
typename SFT::Scalar_factor sfac;
@ -903,8 +903,8 @@ void test_scalar_factor_traits(){
typedef CGAL::Polynomial<EXT_1 > Poly_1_ext_1;
typedef CGAL::Polynomial<Poly_1_ext_1> Poly_2_ext_1;
typedef CGAL::Scalar_factor_traits<Poly_2_ext_1> SFT;
CGAL_assertion_code(typedef typename AT::Integer Scalar;)
CGAL_assertion_code(typedef typename SFT::Scalar Scalar_;)
typedef typename AT::Integer Scalar;
typedef typename SFT::Scalar Scalar_;
CGAL_static_assertion((::boost::is_same<Scalar_, Scalar>::value));
typename SFT::Scalar_factor sfac;

View File

@ -3,14 +3,14 @@
template<class AK>
void test_get_arithmetic_kernel(){
CGAL_assertion_code(typedef typename AK::Integer Integer);
typedef typename AK::Integer Integer;
{
CGAL_assertion_code(typedef CGAL::Polynomial<Integer> POLY;)
CGAL_assertion_code(typedef typename CGAL::Get_arithmetic_kernel<POLY>::Arithmetic_kernel AK_;)
typedef CGAL::Polynomial<Integer> POLY;
typedef typename CGAL::Get_arithmetic_kernel<POLY>::Arithmetic_kernel AK_;
CGAL_static_assertion((boost::is_same<AK,AK_>::value));
}{
CGAL_assertion_code(typedef CGAL::Polynomial<CGAL::Polynomial<Integer> > POLY;)
CGAL_assertion_code(typedef typename CGAL::Get_arithmetic_kernel<POLY>::Arithmetic_kernel AK_;)
typedef CGAL::Polynomial<CGAL::Polynomial<Integer> > POLY;
typedef typename CGAL::Get_arithmetic_kernel<POLY>::Arithmetic_kernel AK_;
CGAL_static_assertion((boost::is_same<AK,AK_>::value));
}
}

View File

@ -77,11 +77,9 @@ int main(int argc, char* argv[]) {
"|- \n";
float item_sec;
#ifndef CGAL_CFG_NO_CPP0X_COPY_N
item_sec = test(v.begin(), n, copy_m, repeats, std_tag());
format_output("stdlib", "vector<int>", "int*", n, item_sec);
std::cout << "|- \n";
#endif
item_sec = test(v.begin(), n, copy_m, repeats, cgal_tag());
format_output("CGAL", "vector<int>", "int*", n, item_sec);
@ -93,11 +91,9 @@ int main(int argc, char* argv[]) {
list l(n);
#ifndef CGAL_CFG_NO_CPP0X_COPY_N
item_sec = test(l.begin(), n, copy_m, repeats, std_tag());
format_output("stdlib", "list<int>", "int*", n, item_sec);
std::cout << "|- \n";
#endif
item_sec = test(l.begin(), n, copy_m, repeats, cgal_tag());
format_output("CGAL", "list<int>", "int*", n, item_sec);
@ -108,11 +104,9 @@ int main(int argc, char* argv[]) {
vector2 v2(n);
copy_mem2 copy_m2 = new non_trivial_cctor[n];
#ifndef CGAL_CFG_NO_CPP0X_COPY_N
item_sec = test(v2.begin(), n, copy_m2, repeats, std_tag());
format_output("stdlib", "vector<non_trivial_cctor>", "non_trivial_cctor*", n, item_sec);
std::cout << "|- \n";
#endif
item_sec = test(v2.begin(), n, copy_m2, repeats, cgal_tag());
format_output("CGAL", "vector<non_trivial_cctor>", "non_trivial_cctor*", n, item_sec);

View File

@ -68,7 +68,6 @@ namespace CGAL {
{
return begin()==end();
}
#ifndef CGAL_CFG_NO_CPP0X_TUPLE
operator std::tuple<I&, I&>()
{
@ -79,8 +78,6 @@ namespace CGAL {
{
return std::tuple<const I&, const I&>{this->first, this->second};
}
#endif
};
template <typename T>

View File

@ -17,11 +17,7 @@
#include <CGAL/Bbox_3.h>
#include <atomic>
#if TBB_IMPLEMENT_CPP0X
# include <tbb/compat/thread>
#else
# include <thread>
#endif
#include <thread>
#include <tbb/enumerable_thread_specific.h>
#include <algorithm>

View File

@ -325,32 +325,6 @@ Uncertain<bool> operator&(Uncertain<bool> a, bool b)
return Uncertain<bool>(a.inf() & b, a.sup() & b);
}
// operator&& and operator|| are not provided because, unless their bool counterpart,
// they lack the "short-circuiting" property.
// We provide macros CGAL_AND and CGAL_OR, which attempt to emulate their behavior.
// Key things : do not evaluate expressions twice, and evaluate the right hand side
// expression only when needed.
// TODO : C++0x lambdas should be able to help here.
#ifdef CGAL_CFG_NO_STATEMENT_EXPRESSIONS
# define CGAL_AND(X, Y) ((X) && (Y))
# define CGAL_OR(X, Y) ((X) || (Y))
#else
# define CGAL_AND(X, Y) \
__extension__ \
({ CGAL::Uncertain<bool> CGAL_TMP = (X); \
CGAL::certainly_not(CGAL_TMP) ? CGAL::make_uncertain(false) \
: CGAL_TMP & CGAL::make_uncertain((Y)); })
# define CGAL_OR(X, Y) \
__extension__ \
({ CGAL::Uncertain<bool> CGAL_TMP = (X); \
CGAL::certainly(CGAL_TMP) ? CGAL::make_uncertain(true) \
: CGAL_TMP | CGAL::make_uncertain((Y)); })
#endif
#define CGAL_AND_3(X, Y, Z) CGAL_AND(X, CGAL_AND(Y, Z))
#define CGAL_AND_6(A, B, C, D, E, F) CGAL_AND(CGAL_AND_3(A, B, C), CGAL_AND_3(D, E,F))
#define CGAL_OR_3(X, Y, Z) CGAL_OR(X, CGAL_OR(Y, Z))
// Equality operators
@ -520,6 +494,38 @@ Uncertain<T> make_uncertain(Uncertain<T> t)
return t;
}
// operator&& and operator|| are not provided because, unless their bool counterpart,
// they lack the "short-circuiting" property.
// We provide macros CGAL_AND and CGAL_OR, which attempt to emulate their behavior.
// Key things : do not evaluate expressions twice, and evaluate the right hand side
// expression only when needed. This is done by using the second value of the macro
// only when required thanks to a lambda that will consume the second expression on demand.
namespace internal{
template <class F_B>
inline Uncertain<bool> cgal_and_impl(const Uncertain<bool>& a, F_B&& f_b)
{
return certainly_not(a) ? make_uncertain(false)
: a & make_uncertain(f_b());
}
template <class F_B>
inline Uncertain<bool> cgal_or_impl(const Uncertain<bool>& a, F_B&& f_b)
{
return certainly(a) ? make_uncertain(true)
: a | make_uncertain(f_b());
}
}
# define CGAL_AND(X, Y) \
::CGAL::internal::cgal_and_impl((X), [&]() { return (Y); })
# define CGAL_OR(X, Y) \
::CGAL::internal::cgal_or_impl((X), [&]() { return (Y); })
#define CGAL_AND_3(X, Y, Z) CGAL_AND(X, CGAL_AND(Y, Z))
#define CGAL_AND_6(A, B, C, D, E, F) CGAL_AND(CGAL_AND_3(A, B, C), CGAL_AND_3(D, E,F))
#define CGAL_OR_3(X, Y, Z) CGAL_OR(X, CGAL_OR(Y, Z))
// make_certain() : Forcing a cast to certain (possibly throwing).
// This is meant to be used only in cases where we cannot easily propagate the

View File

@ -44,10 +44,6 @@
# define CGAL_NO_WARNINGS
#endif
#ifdef CGAL_CFG_NO_CPP0X_STATIC_ASSERT
#include <boost/static_assert.hpp>
#endif
namespace CGAL {
// function declarations
@ -110,48 +106,12 @@ inline bool possibly(Uncertain<bool> c);
# define CGAL_assume_code(CODE) CGAL_assertion_code(CODE)
#endif // no CGAL_NO_ASSERTIONS
#ifndef CGAL_CFG_NO_CPP0X_STATIC_ASSERT
# if defined(CGAL_NO_ASSERTIONS)
# define CGAL_static_assertion(EX) \
static_assert(true, "")
# define CGAL_static_assertion_msg(EX,MSG) \
static_assert(true, "")
# else // no CGAL_NO_ASSERTIONS
# define CGAL_static_assertion(EX) \
# define CGAL_static_assertion(EX) \
static_assert(EX, #EX)
# define CGAL_static_assertion_msg(EX,MSG) \
# define CGAL_static_assertion_msg(EX,MSG) \
static_assert(EX, MSG)
# endif // no CGAL_NO_ASSERTIONS
#else // if CGAL_CFG_NO_CPP0X_STATIC_ASSERT is true
# if defined(CGAL_NO_ASSERTIONS)
# define CGAL_static_assertion(EX) \
BOOST_STATIC_ASSERT(true) CGAL_UNUSED
# define CGAL_static_assertion_msg(EX,MSG) \
BOOST_STATIC_ASSERT(true) CGAL_UNUSED
# else // no CGAL_NO_ASSERTIONS
# define CGAL_static_assertion(EX) \
BOOST_STATIC_ASSERT(EX) CGAL_UNUSED
# define CGAL_static_assertion_msg(EX,MSG) \
BOOST_STATIC_ASSERT(EX) CGAL_UNUSED
# endif // no CGAL_NO_ASSERTIONS
#endif // if CGAL_CFG_NO_CPP0X_STATIC_ASSERT is true
#if defined(CGAL_NO_ASSERTIONS) || !defined(CGAL_CHECK_EXACTNESS)
# define CGAL_exactness_assertion(EX) (static_cast<void>(0))
# define CGAL_exactness_assertion_msg(EX,MSG) (static_cast<void>(0))

View File

@ -22,55 +22,16 @@
- CGAL::cpp11::thread
- CGAL::cpp11::atomic
- CGAL::cpp11::sleep_for
It uses either TBB or STD depending on what's available: as TBB can
quite often override `std::thread`, it is possible that TBB will be
used instead of STD even if the real CXX11 `std::thread` is
available.
As the conflicting API between TBB and STD can be quite complicated,
we offer a more generic `sleep_for()` function that takes
double-typed seconds as argument and deals with it.
*/
#if defined(CGAL_LINKED_WITH_TBB)
# include <tbb/tbb_config.h>
# if TBB_IMPLEMENT_CPP0X
# include <tbb/compat/thread>
# include <atomic>
# include <tbb/tick_count.h>
# define CGAL_USE_TBB_THREADS 1
# else
# define CGAL_USE_TBB_THREADS 0
# endif
#else
# define CGAL_USE_TBB_THREADS 0
#endif
#if !CGAL_USE_TBB_THREADS
# include <thread>
# include <chrono>
#endif
#include <thread>
#include <chrono>
#include <CGAL/atomic.h> // for CGAL::cpp11::atomic
namespace CGAL {
namespace cpp11 {
#if CGAL_USE_TBB_THREADS
using std::thread; // std::thread is declared by TBB if TBB_IMPLEMENT_CPP0X == 1
inline void sleep_for (double seconds)
{
// std::this_thread::sleep_for is declared by TBB if TBB_IMPLEMENT_CPP0X == 1
// It takes interval_t types as argument (!= from the std norm)
std::this_thread::sleep_for(tbb::tick_count::interval_t(seconds));
}
#else // C++11 implementation
using std::thread;
inline void sleep_for (double seconds)
@ -81,20 +42,8 @@ namespace cpp11 {
nanoseconds ns (nanoseconds::rep (1000000000.0 * seconds));
std::this_thread::sleep_for(ns);
}
#endif
#if defined(CGAL_NO_ATOMIC) && defined(CGAL_LINKED_WITH_TBB)
// If <CGAL/atomic.h> did not defined CGAL::cpp11::atomic, then use
// std::atomic as a fallback.
using std::atomic;
#endif
} // cpp11
} //namespace CGAL
#undef CGAL_USE_TBB_THREADS
#endif // CGAL_THREAD_H

View File

@ -26,6 +26,7 @@ namespace CGAL {
namespace IO {
namespace internal {
// @MaelRL Shall we update that code now?
// Ideally this should be a std::is_constructible(double, double, double) but boost::is_constructible
// is not safe to use without CXX11
template <typename Kernel>

View File

@ -21,8 +21,6 @@
#include <CGAL/boost/graph/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#if !defined(CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE) && !defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES)
#include <CGAL/IO/PLY.h>
#ifdef DOXYGEN_RUNNING
@ -1158,6 +1156,4 @@ CGAL_DEPRECATED bool write_ply(std::ostream& os, const Surface_mesh<P>& sm)
} // namespace CGAL
#endif // !defined(CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE) && !defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES)
#endif // CGAL_SURFACE_MESH_IO_PLY_H