Deal with STL_extension

This commit is contained in:
Andreas Fabri 2022-01-18 18:45:42 +00:00
parent 8d749839d8
commit 72b5d0d080
1 changed files with 20 additions and 20 deletions

View File

@ -2,40 +2,40 @@
#include <CGAL/Object.h>
#include <CGAL/assertions.h>
#include <CGAL/use.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <cassert>
void from_opt_var() {
int i = 0;
double j = 0.0;
CGAL_USE(i); CGAL_USE(j);
boost::optional< boost::variant<int, char, double> > v(23);
CGAL::Object o = v;
CGAL_assertion(!o.empty());
CGAL_assertion(CGAL::assign(i, o));
CGAL_assertion(i == 23);
assert(!o.empty());
assert(CGAL::assign(i, o));
assert(i == 23);
//reassign the variant and assign it again
v = 2.0;
o = v;
CGAL_assertion(!CGAL::assign(i, o));
CGAL_assertion(CGAL::assign(j, o));
CGAL_assertion(j == 2.0);
assert(!CGAL::assign(i, o));
assert(CGAL::assign(j, o));
assert(j == 2.0);
//empty optional
boost::optional< boost::variant<int, char, double> > v2;
CGAL::Object o2 = v2;
CGAL_assertion(o2.empty());
assert(o2.empty());
}
void from_var() {
int i = 0;
CGAL_USE(i);
boost::variant<int, char, double> v(23);
CGAL::Object o = v;
CGAL_assertion(!o.empty());
CGAL_assertion(CGAL::assign(i, o));
CGAL_assertion(i == 23);
assert(!o.empty());
assert(CGAL::assign(i, o));
assert(i == 23);
}
struct Foo {
@ -43,19 +43,19 @@ struct Foo {
void make_object_and_assign() {
int i = 23, j = 0;
CGAL_USE(j);
CGAL::Object o = CGAL::make_object(i);
CGAL_assertion(CGAL::assign(j, o));
CGAL_assertion(j == i);
CGAL_assertion(CGAL::object_cast<Foo>(&o) == nullptr);
CGAL_assertion(CGAL::object_cast<int>(&o) != nullptr);
assert(CGAL::assign(j, o));
assert(j == i);
assert(CGAL::object_cast<Foo>(&o) == nullptr);
assert(CGAL::object_cast<int>(&o) != nullptr);
}
void safe_bool() {
CGAL::Object o;
CGAL_assertion(!o);
assert(!o);
CGAL::Object o2 = CGAL::make_object(23);
CGAL_assertion(o2);
assert(o2);
// dummy code, we want to bork on this
// if(o == o2) ;