Skip to content

Replace cpptoml with toml11 v4.4.0 for TOML parsing#108

Merged
yomichi merged 1 commit into
developfrom
update_toml
Jul 11, 2026
Merged

Replace cpptoml with toml11 v4.4.0 for TOML parsing#108
yomichi merged 1 commit into
developfrom
update_toml

Conversation

@yomichi

@yomichi yomichi commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces cpptoml with toml11 v4.4.0 as the TOML parser of the C++ solver. cpptoml is unmaintained (the repository is archived) and supports only TOML v0.5.0, while toml11 is actively maintained, supports TOML v1.0.0, and produces error messages with source locations.

Compatibility

The wrapper layer in load_toml.cpp (find / find_or / load_if / get_array_of) is kept and reimplemented on top of toml11 so that the input semantics do not change:

  • A missing key falls back to the default value or raises input_error; a type mismatch always raises input_error. toml11's own toml::find_or is deliberately not used because it silently swallows type mismatches.
  • An integer value is still accepted where a float is expected (e.g. tau = 1), matching cpptoml's as<double>() behavior. This also applies elementwise to arrays.
  • A scalar is still promoted to a single-element list (e.g. num_step = 100), and an empty sites = [] / index = [] still expands to all sites.

Intentional behavior changes

  • A missing [[evolution.simple]] / [[evolution.full]] now yields an empty update list instead of dereferencing a null pointer (undefined behavior).

  • Writing [observable.onesite] as a single table (instead of an array of tables) is now an error suggesting [[...]], instead of being silently skipped.

  • Type errors now report the file name, line number, and the offending value:

    [INPUT ERROR]
    [error] a value of type integer is required
     --> input.toml
     12 | dimension = "5"
        |             ^^^-- given here
    

Other changes

  • CMake option CPPTOML_ROOT is renamed to TOML11_ROOT.
  • load_toml.cpp no longer depends on boost::core::demangle.
  • Dependency lists in README and the install docs (en/ja) are updated.

Test

  • make + ctest: all 23 tests pass (macOS, g++, MPI off).
  • Manually verified: integer-as-float input is accepted; type errors and missing keys raise input_error with the new messages.

🤖 Generated with Claude Code

cpptoml is unmaintained (archived) and supports only TOML v0.5.0.
Switch to toml11 v4.4.0, which supports TOML v1.0.0 and provides
error messages with source locations.

The wrapper layer (find/find_or/load_if/get_array_of) keeps the
existing input semantics:

- A missing key falls back to the default value or raises input_error;
  a type mismatch always raises input_error (toml11's own find_or
  silently swallows type mismatches, so it is not used).
- An integer value is still accepted where a float is expected
  (e.g. tau = 1), matching cpptoml's as<double>() behavior.
- A scalar is still promoted to a single-element list (e.g.
  num_step = 100).

Intentional behavior changes:

- A missing [[evolution.simple]] / [[evolution.full]] now yields an
  empty update list instead of dereferencing a null pointer (UB).
- Writing [observable.onesite] as a single table (instead of an array
  of tables) is now an error instead of being silently skipped.
- Type errors now report the file name, line, and offending value.

Also drop the boost demangle dependency from load_toml.cpp and update
the dependency lists in README and the install docs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@yomichi yomichi merged commit 60fe819 into develop Jul 11, 2026
22 checks passed
@yomichi yomichi deleted the update_toml branch July 11, 2026 07:49
yomichi added a commit that referenced this pull request Jul 11, 2026
Resolve conflicts between the toml11 migration (#108) and the C++17
modernization:
- src/iTPS/CMakeLists.txt: use TOML11_INCLUDE_DIR and keep boost removed
- src/iTPS/load_toml.cpp: adopt the toml11 wrappers from develop,
  rewritten with C++17 idioms (if constexpr, _v traits, structured
  bindings); drop the cpptoml-era bittype/demangle helpers

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@yomichi yomichi mentioned this pull request Jul 11, 2026
4 tasks
yomichi added a commit that referenced this pull request Jul 11, 2026
Summarize the changes merged since v2.1.3 (#104, #107, #108, #109):
mptensor v0.5.0 / C++17 requirement, cpptoml -> toml11 migration,
icpx and link-error fixes, and the C++17 modernization.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant