https://github.com/heroickatora/mould
A c++17 constexpr formatting library utilizing bytecode representation
https://github.com/heroickatora/mould
Last synced: 3 months ago
JSON representation
A c++17 constexpr formatting library utilizing bytecode representation
- Host: GitHub
- URL: https://github.com/heroickatora/mould
- Owner: HeroicKatora
- License: bsd-3-clause
- Created: 2018-02-28T00:58:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-05-31T23:18:02.000Z (about 3 years ago)
- Last Synced: 2023-08-12T16:21:15.403Z (almost 2 years ago)
- Language: C++
- Size: 126 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License
Awesome Lists containing this project
README
A format library with Python syntax, sane defaults, fast. For compile-time C++.
Compatible with C++17 and upwards.
-----------
Implements the `formatlib` benchmark in [speed.cpp](./test/run.cpp).
Tested with `-std=c++20` as it includes bit tricks for faster code.| test name | run time | executable size (stripped) |
|-----------|---------:|---------------------------:|
| gcc | 0.253s | 135kB |
| clang | 0.140s | 43kB |------------
C++17 accepted `fmt` in its worst form, with runtime format templates. The
independent library's implementation later at least added type-checked
arguments but the internals are not constexpr ready enough to where the
compiler could really optimize on.We go further. The biggest difference to the accepted standard draft is gather
all character formatting, type safety and additional information about the
minimum, maximum, heuristic length of arguments, `std::numeric_limits` et.al.
This information can theoretically be used at compile time when determining an
optimal formatting strategy. The library allows types to provide a formatter
lookup, that finds any function based on the statically encoded format
arguments.