Skip to content

Conversation

@mlund
Copy link
Owner

@mlund mlund commented Jan 9, 2026

Summary

  • Replace third-party headers with C++20 standard equivalents (fmt::formatstd::format)
  • Extract utilities from core.h to dedicated headers (json_support.h, eigensupport.h, coordinates.h, usagetip.h, electrolyte.h)
  • Remove backwards-compatibility includes from core.h, requiring explicit includes
  • Remove redundant includes across headers (includes already provided transitively)
  • Use nlohmann/json_fwd.hpp forward declaration in tensor.h
  • Update PCH configuration to use <format> instead of spdlog/fmt

Test plan

  • Build with clang succeeds
  • Run unit tests
  • Verify no functionality changes

🤖 Generated with Claude Code

mlund and others added 14 commits January 9, 2026 12:45
- Replace <Eigen/Dense> with lighter <Eigen/Core> in energy.h
- Add <Eigen/Eigenvalues> to analysis.cpp where SelfAdjointEigenSolver is used

This reduces compilation time for the heaviest header file (energy.h, ~2000 lines)
by avoiding unnecessary Eigen decomposition modules.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace <spdlog/fmt/fmt.h> with <format> for GenericError template
- Replace <range/v3/range/concepts.hpp> with <iterator> for iter_value_t
- Use std::format instead of fmt::vformat in GenericError
- Use std::iter_value_t instead of ranges::cpp20::iter_value_t

This removes two third-party library includes from the most widely
included header file, potentially improving compilation times.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Migrate from spdlog's bundled fmt library to C++20 std::format:
- Update all fmt::format calls to std::format
- Replace <spdlog/fmt/fmt.h> and <spdlog/fmt/ostr.h> with <format>
- Add <format> include to headers that use std::format

This reduces dependency on third-party formatting and uses
the C++20 standard library instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace <spdlog/fmt/fmt.h> with <format> in precompiled headers
to match the migration from fmt::format to std::format.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move BoundaryFunction and DistanceFunction to core.h
- Remove geometry.h include from group.h (use units.h for pc::)
- Add geometry.h to group.cpp and externalpotential.h where needed
- Remove duplicate typedef from bonds.h

Files like io.h, regions.h and their dependents no longer
transitively include the 952-line geometry.h.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Headers that include core.h no longer need to explicitly include:
- <ranges>, <optional>, <vector>, <iterator>, <functional>
- <nlohmann/json.hpp>

These are already provided by core.h.

Also reorder celllistimpl.h to include core.h first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- energy.h: remove Eigen/Core, ranges, optional (from space.h->core.h)
- io.h: remove iterator, ranges (from group.h->core.h)
- move.h: remove optional (from space.h->core.h)
- analysis.h: remove vector (from space.h->core.h)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove <optional> and <ranges> which are already provided
via regions.h -> space.h -> core.h

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move specialized utilities out of core.h to improve modularity:
- aux/json_support.h: JSON utilities (SingleUseJSON, loadJSON, etc.)
- aux/coordinates.h: Coordinate transforms (xyz2rth, xyz2rtp, rtp2xyz)
- aux/usagetip.h: TipFromTheManual class
- electrolyte.h: Electrolyte class and makeElectrolyte
- aux/eigensupport.h: Added asEigenMatrix, asEigenVector functions
- random.h: Added randomUnitVector, randomUnitVectorPolar functions
- io.h: Added addGrowingSuffix function

Core.h now includes these headers for backwards compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Each source file now explicitly includes the headers it needs
(json_support.h, eigensupport.h, coordinates.h, usagetip.h, electrolyte.h)
rather than relying on transitive includes through core.h.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- analysis.h: remove particle.h, molecule.h (provided by space.h)
- bonds.h: remove core.h (provided by particle.h)
- energy.h: remove aux/iteratorsupport.h (unused in header)
- molecule.h: remove core.h (provided by particle.h)
- move.h: remove geometry.h, molecule.h (provided by space.h)
- montecarlo.cpp: add aux/iteratorsupport.h (was transitive via energy.h)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace full nlohmann/json.hpp with lightweight json_fwd.hpp since
only function declarations use the json type (by reference).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
libstdc++ on Debian bookworm lacks <format> header support.
Switch to libc++ which has full C++20 standard library support.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Ensures external dependencies are built with the same stdlib flags
(e.g., -stdlib=libc++) as the main project to avoid ABI mismatches.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mlund mlund added the code quality ⚙️ Code refactoring / restructuring label Jan 9, 2026
@mlund mlund merged commit 42f3f25 into master Jan 9, 2026
4 checks passed
@mlund mlund deleted the include_optimization branch January 9, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality ⚙️ Code refactoring / restructuring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants