Search⌘ K
AI Features

Elementary string conversions

Explore how C++17 introduces efficient string conversions with from_chars and to_chars that improve performance by avoiding exceptions, memory allocation, and locale overhead. Understand how these functions enable safe, low-level parsing and formatting of numbers from and to strings, making them ideal for processing data formats like JSON and XML.

The growing number of data formats like JSON or XML require efficient string processing and manipulation. The maximum performance is especially crucial when such data formats are used to communicate over the network, where high throughput is the critical factor.

For example, you get the characters in a network packet, you deserialise it (convert strings into numbers), then process the data, and finally, it’s serialised back to the same file format (numbers into strings) and sent over the network as a response.

The Standard Library had bad luck in those areas. It’s usually perceived to be too slow for such advanced string processing. Often developers prefer custom solutions or third-party libraries.

The situation might change as with C++17 we get two sets of functions: from_chars and to_chars that allow for low-level string conversions.

Current Solutions Summaries Table

...