csv-parser v5.7.0
Permanent link:
cppdashboard.dev/r/2026/10/csv-parser-v5-7-0A modern C++ CSV parser and serializer that doesn't make you choose between ease of use or performance.
Release notes
## Clearer iterator and field semantics
**v5.7.0 fixes use-after-free problems in `CSVRow` field iteration.** In the previous implementation, reverse dereference could return a reference to a `CSVField` owned by a temporary iterator. That iterator was destroyed before the caller could read the field. Even copying the result could access a freed wrapper:
```cpp
CSVField last = *row.rbegin(); // Could read freed memory in the previous version.
```
A saved reference from forward iteration could likewise dangle after its iterator advanced to another field or was destroyed. Accessing those dangling references was undefined behavior.
Those failures motivated clearer, more consistent iterator and field semantics: what rows and fields own, how long their views remain valid, and how lazy conversion caches interact with const reads.
`CSVField` remains a lightweight wrapper around existing CSV text, with its own lazy conversion cache. **The change is that `CSVRow` iterator dereference now returns `CSVField` by value instead of a reference to an iterator-owned wrapper.** Indexed access such as `row[i]` already returned values. This brings field iteration into line with indexed access and fixes the wrapper-lifetime problem exposed by temporary iterator copies.
## Reading fields and migrating loops
Ordinary field predicates and conversions are now logically const. They may fill a private cache without changing the field's text or interpretation, so the same read-only idiom works for rows and fields:
```cpp
for (const auto& row : reader) {
for (const auto& field : row) {
// field.is_num(), field.get<T>(), and field.try_get(out) are const.
}
}
```
**Existing `auto& field` loops need to change to `const auto& field` or `auto field`.** A const field reference extends the returned wrapper's lifetime through the loop body. A local field value is also useful when retaining conversion results or explicitly changing decimal interpretation.
Calling `is_num()` followed by `get<double>()` reuses the cached classification. Explicit custom decimal interpretation through `try_parse_decimal()` still requires a non-const field. Separate field values keep independent caches; there is no chunk-wide field-wrapper cache.
## Ownership and lifetime
- `CSVReader` row iteration remains single-pass. A row reference borrows the iterator's current row; copying a `CSVRow` shares its backing storage without copying CSV text.
- Field iterators now capture their original row span and retain its backing chunk. Reassigning, moving, or destroying the source row no longer redirects an existing field iterator.
- A `CSVField` still borrows its text. Keep a row or field iterator for the backing chunk alive while using the field or its string views. Extending a wrapper's lifetime does not extend the lifetime of its text by itself.
See the [field iteration guide](https://github.com/vincentlaucsb/csv-parser/blob/master/docs/source/row_iterators.md) for lifetime and compatibility details.
## Fixes and improvements
- Fix the `CSVRow` reverse-iterator use-after-free and make forward/reverse dereference and indexing produce field values safely.
- Support C++20 standard reverse iterators, `std::views::reverse`, composed views, and modern random-access iterator concepts.
- Preserve C++11 support and the library's `row.rbegin()` / `row.rend()`. The legacy field-iterator category is now input; older-standard algorithms requiring forward or random-access categories should first materialize owning strings or numeric values.
- Keep iterator construction, navigation, and arrow proxies free of field-wrapper heap allocations.
- Make optional/expected conversions and hexadecimal/timestamp reads const-compatible, and remove the corresponding `const_cast` workarounds from DataFrame-cell reads.
- Upgrade the compiler-backed single-header distribution generator to `single_header` 1.2.0.
## Changes since v5.6.0
- [Single… Share this resource