gtopt/fmap.hpp file

flat_map type alias and map utility helpers

This module defines the flat_map alias and two map utility helpers:

map_reserve(map, n) Reserve capacity for n elements. No-op for std::map.

map_insert_sorted_unique(map, first, last) Insert from a pre-sorted, deduplicated range using the most efficient API for each backend.

Backend selection (can be overridden by defining one of the macros before including this header):

GTOPT_USE_STD_FLAT_MAP - std::flat_map (default for GCC >= 15 and Clang >= 23, only when <flat_map> is available) GTOPT_USE_BOOST_FLAT_MAP - boost::container::flat_map (default for all other compilers / older versions) GTOPT_USE_STD_MAP - std::map (not used by default; available as an explicit override)

Namespaces

namespace gtopt

Defines

#define GTOPT_USE_STD_MAP