A Conversion Story: Improving from_chars and to_chars in C++17
summary
Provides tiny wrapper templates that eliminate the end pointer by taking arrays by reference or containers with contiguous storage and calling std::from_chars/std::to_chars, so callers pass a string, array, string_view or vector without computing length. Code remains one-line thin wrappers that preserve from_chars semantics (no hidden allocation, no implicit null termination), explicitly rejects bool conversions and notes a compiler bug tracked as LWG 3266. Also suggests optional preallocation to avoid repeated growth.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 0:36What is a conversion
- 0:47Conversion functions
- 3:01Floating point types
- 3:16Usage
- 3:53Making it better
- 4:11What if
- 4:47Array
- 5:50Utility header
- 6:29Helpers
- 6:40Integers
- 7:19Containers
- 7:29Floating
related talks
51mTypical C++, but Why?
54mTypical C++, But Why?
01h 05mThe Many Faces of Number ⟷ String Conversions
56mC++17: The Library Features
52mC++ Performance Tips - Cutting Down on Unnecessary Objects
57mIntroduction to C++ Template Metaprogramming
01h 03mC++17 part 2: The Library Features
01h 35mC++20 – My Favourite Code Examples
