Skip to content

1.1.1

Latest

Choose a tag to compare

@jkalias jkalias released this 15 Jun 13:49
3a5c2ea

Bug fixes, a safety improvement, and performance work since 1.1.0. No source changes are required to upgrade.

Bug fixes

  • fcpp::set::min() / max() now respect the set's comparator and run in O(1). Previously they used std::min_element/std::max_element, which rank by operator< and could return the wrong element for sets with a custom comparator.
  • fcpp::set::operator[] (non-const) no longer fails to compile.
  • fcpp::optional (the pre-C++17 fallback): fixed a memory leak on copy-assignment and a value-loss bug on self-assignment.
  • fcpp::set iterator accessors now declare their return types with the set's comparator, fixing fragile type assumptions for custom-comparator sets.

Safety: consistent precondition checks

  • Precondition checks (subscript bounds, replace_range_at, zip on unequal sizes) are now enforced identically in debug and release builds via std::abort(). Previously these were asserts that were compiled out under NDEBUG, so release builds could silently invoke undefined behavior / buffer overflows.
  • index_range hardened against signed-integer overflow, and its invalid sentinel is now const.
  • New opt-out: define FCPP_NO_PRECONDITION_CHECKS to compile the checks out for hot paths whose inputs are already validated.

Performance

  • Eliminated unnecessary container copies across non-mutating operations (filtered, sorted, removing_*, inserting_*, replacing_range_at, map, and the set/map equivalents) by moving internal containers into the returned wrapper instead of copying them.
  • insert_back no longer copies the inserted element twice, and set::keys() no longer performs a pessimizing move.

Compatibility

  • No public API changes. C++11 and C++17 supported as before.
  • Behavior change to note: a precondition violation now reliably terminates the process in release builds (it was undefined behavior before). Code that previously relied on that UB "happening to work" should be reviewed.