// 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_SET # define CGAL_USE_BARE_STD_MAP CGAL_USE_BARE_STD_SET #endif #if CGAL_USE_BARE_STD_MAP // to benchmark with the ordered std::map # include # include #elif CGAL_USE_BOOST_UNORDERED # include # include #else // Boost before 1.81.0, use the C++11 std::unordered_map # include # include #endif #include // for std::hash, std::equal_to #include // for std::allocator namespace CGAL { namespace internal_is_hashable { using boost::hash_value; template struct Has_hash_value : std::false_type {}; template using hash_value_type = decltype(hash_value(std::declval())); template struct Has_hash_value>> : std::is_convertible, std::size_t> {}; } template inline constexpr bool is_hashable_v = internal_is_hashable::Has_hash_value::value && std::is_default_constructible_v>; 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 Boost implementation of C++11 std::unordered_map (for noexcept) using unordered_flat_map = boost::unordered_map; #endif template < typename Key, typename Hash = std::hash, typename KeyEqual = std::equal_to, typename Allocator = std::allocator > #if CGAL_USE_BARE_STD_MAP using unordered_flat_set = std::set, Allocator>; #elif CGAL_USE_BOOST_UNORDERED using unordered_flat_set = boost::unordered_flat_set; #else // use the Boost implementation of C++11 std::unordered_set (for noexcept) using unordered_flat_set = boost::unordered_set; #endif } // end namespace CGAL #endif // CGAL_UNORDERED_FLAT_MAP_H