diff --git a/STL_Extension/include/CGAL/Object.h b/STL_Extension/include/CGAL/Object.h index 6046e22552a..fdfd59bd514 100644 --- a/STL_Extension/include/CGAL/Object.h +++ b/STL_Extension/include/CGAL/Object.h @@ -76,25 +76,10 @@ class Object template bool assign(T &t) const { - if(obj) { - #ifdef CGAL_USE_ANY_BAD_CAST - try { - t = boost::any_cast(*obj); - return true; - } catch(...) { - return false; - } - #else - const T* res = boost::any_cast(&(*obj)); - if (res){ - t=*res; - return true; - } - return false; - #endif - } else { - return false; - } + const T* res = boost::any_cast(obj.get()); + if (!res) return false; + t = *res; + return true; } bool @@ -174,19 +159,13 @@ template inline const T * object_cast(const Object * o) { - if(o->obj) - return boost::any_cast((o->obj).get()); - else - return nullptr; + return boost::any_cast((o->obj).get()); } template inline T object_cast(const Object & o) { - if(!o.obj) - throw Bad_object_cast(); - const T * result = boost::any_cast((o.obj).get()); if (!result) throw Bad_object_cast();