diff --git a/CGAL_Core/examples/Core/CMakeLists.txt b/CGAL_Core/examples/Core/CMakeLists.txt index d4513e22dea..6d9e732db93 100644 --- a/CGAL_Core/examples/Core/CMakeLists.txt +++ b/CGAL_Core/examples/Core/CMakeLists.txt @@ -9,4 +9,5 @@ if(NOT CGAL_Core_FOUND) return() endif() +create_single_source_cgal_program("zero-one.cpp") create_single_source_cgal_program("delaunay.cpp") diff --git a/CGAL_Core/examples/Core/zero-one.cpp b/CGAL_Core/examples/Core/zero-one.cpp new file mode 100644 index 00000000000..cfc5a903c19 --- /dev/null +++ b/CGAL_Core/examples/Core/zero-one.cpp @@ -0,0 +1,32 @@ + +#include + +typedef CORE::Expr Real; + +int main() +{ + Real r(3.14); + + CGAL::is_zero(r); + + CGAL::is_one(r); + + r = CGAL::sqrt(r); + + + CGAL::is_zero(r); + + CGAL::is_one(r); + + r = r * r; + + CGAL::is_zero(r); + + CGAL::is_one(r); + + r = r - r; + + CGAL::is_zero(r); + + return 0; +} diff --git a/Number_types/include/CGAL/CORE_Expr.h b/Number_types/include/CGAL/CORE_Expr.h index ae0b603b1ed..efeb5ad9363 100644 --- a/Number_types/include/CGAL/CORE_Expr.h +++ b/Number_types/include/CGAL/CORE_Expr.h @@ -115,6 +115,14 @@ template <> class Algebraic_structure_traits< CORE::Expr > }; */ }; + class Is_zero + : public CGAL::cpp98::unary_function< Type, bool > { + public: + bool operator()( const Type& x ) const { + return x.isZero(); + } + }; + }; template <> class Real_embeddable_traits< CORE::Expr >