Glaze v7.0.1
Highlights
- Reduced binary size for embedded and size-constrained environments (use
glz::size_optsandGLZ_DISABLE_ALWAYS_INLINE) - TOML support for
std::variantand generic types (glz::generic, maps) - Optimized floating-point parsing
- Fixed sparse enums with large values (#2246)
Binary Size Optimization
This release focuses heavily on reducing binary size for embedded systems and size-constrained environments.
std::error_code Integration Moved to Optional Header
The unused std::error_code integration has been moved from the core headers to a separate optional header:
#include <glaze/core/std_error_code.hpp>This reduces binary size by ~34KB for users who don't need std::error_code compatibility. The overhead came from the global error_category variable with std::error_category vtable, which forced a DATA segment with page alignment overhead.
Breaking Change: If your code uses glz::error_category, glz::make_error_code(), or relies on implicit conversion from glz::error_code to std::error_code, you must now explicitly include the header:
#include <glaze/core/std_error_code.hpp>Size-Optimized Float Parsing (simple_float.hpp)
A new compact floating-point parsing and serialization module achieves ~21-25KB savings compared to the full dragonbox/fast_float implementations:
- Maintains strict JSON compliance
- Verified to roundtrip with all of Glaze's floating point algorithms, so no changes occur when switching from
glz::opts_sizeand peak performance algorithms
This is automatically used when serializing/deserializing with glz::opts_size.
TOML Improvements
Variant and Generic Type Support (#2240)
Full TOML serialization support for:
std::varianttypes with automatic type detection- Generic types:
glz::generic,glz::generic_i64,glz::generic_u64 - Map types:
std::map,std::unordered_map
std::variant<int, double, std::string> value = 3.14;
std::string toml;
glz::write<glz::TOML>(value, toml);
// toml: "3.14"Features:
- Automatic type detection from TOML syntax (quoted strings, booleans, arrays, objects, floats, integers)
- Dotted keys and table sections within map contexts
- Path-based nested map navigation for type safety
Bug Fixes
Sparse Enums with Large Values (#2246)
Fixed compilation failure for enums with values that share common power-of-2 factors:
enum class SparseEnum : int {
Zero = 0,
FourHundredMillion = 400000000 // Previously failed to compile
};The issue occurred because values like 0 and 400000000 (both divisible by 2^10) would hash to the same bucket with standard modular hashing, causing "Failed to find perfect hash seed for enum" errors.
Solution: Added a new modular_shifted hash strategy that removes common trailing zeros before hashing. The compiler automatically selects this strategy when standard modular hashing fails.