- Refine CGAL_AND or CGAL_OR to make sure they work when the second argument is a bool.

- Add CGAL_AND_3 and CGAL_OR_3 for 3-arguments boolean operations.
This commit is contained in:
Sylvain Pion 2008-08-12 11:23:34 +00:00
parent 82d1bbc800
commit 0c34dc2525
3 changed files with 16 additions and 2 deletions

View File

@ -320,6 +320,9 @@ Another option is :
... // Use res ... // Use res
\end{ccExampleCode} \end{ccExampleCode}
For convenience, the macros \ccc{CGAL_AND_3} and \ccc{CGAL_OR_3} are also
provided to support boolean operations with 3 arguments instead of 2.
%% +-----------------------------------+ %% +-----------------------------------+
\ccHeading{Overloaded operators and functions for \ccc{Uncertain<enum T>} only} \ccHeading{Overloaded operators and functions for \ccc{Uncertain<enum T>} only}

View File

@ -319,12 +319,17 @@ Uncertain<bool> operator&(Uncertain<bool> a, bool b)
#else #else
# define CGAL_AND(X, Y) \ # define CGAL_AND(X, Y) \
({ CGAL::Uncertain<bool> CGAL_TMP = (X); \ ({ CGAL::Uncertain<bool> CGAL_TMP = (X); \
CGAL::certainly_not(CGAL_TMP) ? CGAL::make_uncertain(false) : CGAL_TMP & (Y); }) CGAL::certainly_not(CGAL_TMP) ? CGAL::make_uncertain(false) \
: CGAL_TMP & CGAL::make_uncertain((Y)); })
# define CGAL_OR(X, Y) \ # define CGAL_OR(X, Y) \
({ CGAL::Uncertain<bool> CGAL_TMP = (X); \ ({ CGAL::Uncertain<bool> CGAL_TMP = (X); \
CGAL::certainly(CGAL_TMP) ? CGAL::make_uncertain(true) : CGAL_TMP | (Y); }) CGAL::certainly(CGAL_TMP) ? CGAL::make_uncertain(true) \
: CGAL_TMP | CGAL::make_uncertain((Y)); })
#endif #endif
#define CGAL_AND_3(X, Y, Z) CGAL_AND(X, CGAL_AND(Y, Z))
#define CGAL_OR_3(X, Y, Z) CGAL_OR(X, CGAL_OR(Y, Z))
// Equality operators // Equality operators

View File

@ -243,6 +243,9 @@ void test_bool()
bool_assert(CGAL_AND(utrue, utrue)); bool_assert(CGAL_AND(utrue, utrue));
bool_assert(!CGAL_AND(ufalse, ufalse)); bool_assert(!CGAL_AND(ufalse, ufalse));
bool_assert(CGAL_AND_3(true, true, true));
bool_assert(!CGAL_AND_3(true, false, true));
bool_assert(CGAL_OR(true, false)); bool_assert(CGAL_OR(true, false));
bool_assert(CGAL_OR(false, true)); bool_assert(CGAL_OR(false, true));
bool_assert(CGAL_OR(true, true)); bool_assert(CGAL_OR(true, true));
@ -252,6 +255,9 @@ void test_bool()
bool_assert(CGAL_OR(utrue, utrue)); bool_assert(CGAL_OR(utrue, utrue));
bool_assert(!CGAL_OR(ufalse, ufalse)); bool_assert(!CGAL_OR(ufalse, ufalse));
bool_assert(CGAL_OR_3(false, false, true));
bool_assert(!CGAL_OR_3(false, false, false));
try { try {
bool_assert( CGAL_AND(utrue, utrue)); bool_assert( CGAL_AND(utrue, utrue));
bool_assert(!CGAL_AND(ufalse, ufalse)); bool_assert(!CGAL_AND(ufalse, ufalse));