// Copyright (c) 2013 Tel-Aviv University (Israel). // All rights reserved. // // This file is part of CGAL (www.cgal.org). // // $URL: https://github.com/CGAL/cgal/blob/v5.1/Arrangement_on_surface_2/include/CGAL/Arr_point_location_result.h $ // $Id: Arr_point_location_result.h 254d60f 2019-10-19T15:23:19+02:00 Sébastien Loriot // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Efi Fogel #ifndef CGAL_ARR_POINT_LOCATION_RESULT_H #define CGAL_ARR_POINT_LOCATION_RESULT_H #include #include // The macro CGAL_ARR_POINT_LOCATION_VERSION controls which version of the // point location is used. Currently two values are supported: // 1. Point location with CGAL::Object // 2. Point location with boost::optional > // The default value is 2. #if !defined(CGAL_ARR_POINT_LOCATION_VERSION) #define CGAL_ARR_POINT_LOCATION_VERSION 2 #endif #include #include #include #ifdef CGAL_CFG_BOOST_VARIANT_SWAP_BUG #if CGAL_ARR_POINT_LOCATION_VERSION > 1 #include // workaround for this bug: // https://svn.boost.org/trac/boost/ticket/2839 namespace boost{ namespace detail { namespace variant { template inline void move_swap( ::CGAL::I_Filtered_const_iterator& lhs, ::CGAL::I_Filtered_const_iterator& rhs) { ::CGAL::I_Filtered_const_iterator tmp( boost::detail::variant::move(lhs) ); lhs = boost::detail::variant::move(rhs); rhs = boost::detail::variant::move(tmp); } } } } #endif #endif namespace CGAL { template struct Arr_point_location_result { typedef Arrangement_ Arrangement_2; typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; typedef typename Arrangement_2::Face_const_handle Face_const_handle; #if CGAL_ARR_POINT_LOCATION_VERSION < 2 typedef CGAL::Object Type; #else typedef typename boost::variant Type; #endif typedef Type type; // This function returns either make_object() or a result_type constructor // to generate return values. The Object version takes a dummy template // argument, which is needed for the return of the other option, e.g., // boost::optional >. // In theory a one parameter variant could be returned, but this _could_ // lead to conversion overhead, and so we rather go for the real type. // Overloads for empty returns are also provided. #if CGAL_ARR_POINT_LOCATION_VERSION < 2 template static inline CGAL::Object make_result(T t) { return CGAL::make_object(t); } static inline CGAL::Object empty_optional_result() { return CGAL::Object(); } template const T* assign(CGAL::Object obj) const { return CGAL::object_cast(&obj); } #else template static inline Type make_result(T t) { return Type(t); } inline static boost::optional empty_optional_result() { return boost::optional(); } template const T* assign(const Type& obj) const { return boost::get(&obj); } #endif // CGAL_ARR_POINT_LOCATION_VERSION < 2 //this one is only to remove warnings in functions static inline Type default_result(){ CGAL_error_msg("This functions should never have been called!"); return Type(); } }; } //namespace CGAL #include #endif