diff --git a/STL_Extension/include/CGAL/unordered_flat_map.h b/STL_Extension/include/CGAL/unordered_flat_map.h new file mode 100644 index 000000000000..45470c04d48b --- /dev/null +++ b/STL_Extension/include/CGAL/unordered_flat_map.h @@ -0,0 +1,60 @@ +// Copyright (c) 2025 GeometryFactory Sarl (France). +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Laurent Rineau + +#ifndef CGAL_UNORDERED_FLAT_MAP_H +#define CGAL_UNORDERED_FLAT_MAP_H + +#include + +#include +#if BOOST_VERSION >= 108100 && !defined(CGAL_USE_BOOST_UNORDERED) +# define CGAL_USE_BOOST_UNORDERED 1 +#endif + +#if CGAL_USE_BARE_STD_MAP // to benchmark with the ordered std::map +# include +#elif CGAL_USE_BOOST_UNORDERED +# include +#else // Boost before 1.81.0, use the C++11 std::unordered_map +# include +#endif + +#if CGAL_USE_BARE_STD_MAP + #include +#endif + +#include + +namespace CGAL { + +template < + typename Key, + typename T, + typename Hash = std::hash, + typename KeyEqual = std::equal_to, + typename Allocator = std::allocator> + > +#if CGAL_USE_BARE_STD_MAP + + using unordered_flat_map = std::map, Allocator>; + +#elif CGAL_USE_BOOST_UNORDERED + + using unordered_flat_map = boost::unordered_flat_map; + +#else // use the C++11 std::unordered_map + + using unordered_flat_map = std::unordered_map; + +#endif + +} // end namespace CGAL + +#endif // CGAL_UNORDERED_FLAT_MAP_H diff --git a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h index b96752e91fe5..6be1e8dd401b 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2/internal/Polyline_constraint_hierarchy_2.h @@ -22,14 +22,7 @@ #include #include -#include -#if BOOST_VERSION >= 108100 -# include -# define CGAL_USE_BOOST_UNORDERED 1 -#else // BOOST before 1.81.0 -# include -#endif - +#include #include #include @@ -162,11 +155,7 @@ class Polyline_constraint_hierarchy_2 typedef typename Context_list::iterator Context_iterator; typedef std::set Constraint_set; -#if CGAL_USE_BOOST_UNORDERED - typedef boost::unordered_flat_map> Sc_to_c_map; -#else - typedef std::unordered_map> Sc_to_c_map; -#endif + typedef CGAL::unordered_flat_map> Sc_to_c_map; typedef typename Constraint_set::iterator C_iterator; typedef typename Sc_to_c_map::const_iterator Sc_iterator; typedef Sc_iterator Subconstraint_iterator;