# C++23

Published articles for C++23.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Billion-query-per-second lookup tables in C++

DevFeed: [Billion-query-per-second lookup tables in C++](<https://devfeed.tech/articles/billion-query-per-second-lookup-tables-in-c-101123.md>)

Original publisher: [Read original article](<https://lemire.me/blog/2026/10/26/billion-query-per-second-lookup-tables-in-c/>)

Author: Daniel Lemire

Published: 2026-10-26T18:23:08Z

Content type: article

Language: en

Sources: [Daniel Lemire](<https://devfeed.tech/sources/daniel-lemire.md>)

Topics: [stl](<https://devfeed.tech/topics/stl.md>), [clang](<https://devfeed.tech/topics/clang.md>), [Parser](<https://devfeed.tech/topics/parser.md>)

Tags: [abseil](<https://devfeed.tech/tags/abseil.md>), [algorithm](<https://devfeed.tech/tags/algorithm.md>), [apple](<https://devfeed.tech/tags/apple.md>), [arm](<https://devfeed.tech/tags/arm.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [branch](<https://devfeed.tech/tags/branch.md>), [buffer](<https://devfeed.tech/tags/buffer.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [lookup](<https://devfeed.tech/tags/lookup.md>), [mapping](<https://devfeed.tech/tags/mapping.md>), [tables](<https://devfeed.tech/tags/tables.md>)

### AI overview

For fixed string keys, the described C++23 library builds a perfect hash at compile time, avoiding runtime collision handling. It chooses association values greedily for selected key characters; lookup computes a slot and verifies the stored key. The implementation also uses a 16-byte vector comparison, with a slower path when a wide load could cross a memory-page boundary. On an Apple M3 Max, the article reports about 1.3 ns per lookup for 20 HTTP headers, versus 7.7 ns for gperf, 10.9 ns for Abseil flat_hash_map, and 16.6 ns for std::unordered_map. Across other tested key sets it reports 1.2-2 ns per lookup; results are specific to the stated benchmarks and hardware.

### Source excerpt

A lot of software spends its time mapping strings to values. A web server must identify the HTTP method (GET, POST, ...). It must recognize header names. A URL parser must recognize the protocol (http, https, ftp, ...). A compiler must recognize keywords. In C++, the default approach is to put the strings in a ... Continue reading Billion-query-per-second lookup tables in C++

## MSVC Build Tools Version 14.52 Release Candidate Now Available

DevFeed: [MSVC Build Tools Version 14.52 Release Candidate Now Available](<https://devfeed.tech/articles/msvc-build-tools-version-14-52-release-candidate-now-available-88249.md>)

Original publisher: [Read original article](<https://devblogs.microsoft.com/cppblog/msvc-build-tools-version-14-52-release-candidate-now-available/>)

Author: Eric Brumer

Published: 2026-10-15T20:07:03Z

Content type: release

Language: en

Sources: [C++ Team Blog](<https://devfeed.tech/sources/c-team-blog.md>)

Topics: [MSVC](<https://devfeed.tech/topics/msvc.md>), [c/c++](<https://devfeed.tech/topics/c-c-plus-plus.md>), [version](<https://devfeed.tech/topics/version.md>), [Build tool](<https://devfeed.tech/topics/build-tool.md>), [versioning](<https://devfeed.tech/topics/versioning.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [msvc](<https://devfeed.tech/tags/msvc.md>), [release](<https://devfeed.tech/tags/release.md>)

### AI overview

Microsoft announces the release candidate for MSVC Build Tools 14.52, with C++23 available for production use through `/std:c++23`. The release includes updates to language support, optimization and code generation, ARM64 and x64 targets, the standard library, AddressSanitizer, and build tools and diagnostics. The post also lists fixes reported during development.

### Source excerpt

We are pleased to announce the availability of the release candidate for Microsoft C++ (MSVC) Build Tools version 14.52. With this release, C++23 is ready for production use and available through the /std:c++23 compiler option; see below for details. This is the last MSVC v14.52 preview before it moves to stable status and full support. [...] The post MSVC Build Tools Version 14.52 Release Candidate Now Available appeared first on C++ Team Blog.

## C++26 Ranges: Four New Views

DevFeed: [C++26 Ranges: Four New Views](<https://devfeed.tech/articles/c-26-ranges-four-new-views-86853.md>)

Original publisher: [Read original article](<https://www.sandordargo.com/blog/2026/10/14/cpp26-ranges-part-1-new-views>)

Author: Sandor Dargo

Published: 2026-10-13T22:00:00Z

Content type: article

Language: en

Sources: [Sandor Dargo's Blog](<https://devfeed.tech/sources/sandor-dargo-s-blog.md>)

Topics: [data type](<https://devfeed.tech/topics/data-type.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-20](<https://devfeed.tech/tags/c-plus-plus-20.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [c-plus-plus-26](<https://devfeed.tech/tags/c-plus-plus-26.md>), [dev](<https://devfeed.tech/tags/dev.md>)

### AI overview

The article explains four C++26 ranges views: `views::concat` for lazy iteration across ranges, `views::to_input` to simplify iterator behavior and reduce work, `views::cache_latest` to avoid repeated transform evaluations, and `views::indices` for generating an index range. It also describes constraints and behavior of each view.

### Source excerpt

C++20 shipped a powerful ranges library, but the set of view adaptors had some obvious gaps. Want to get the output as a container? No luck. At least C++23 helped with that. Want to iterate over two vectors as one sequence? Write your own. Want to avoid redundant evaluations in a transform | filter pipeline? Write a workaround. Want a quick index sequence matching a range's size? Spell out iota...

## Using C++17 std::optional

DevFeed: [Using C++17 std::optional](<https://devfeed.tech/articles/using-c-17-std-optional-61110.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2018/05/using-optional/>)

Published: 2026-09-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [Memory Safety](<https://devfeed.tech/topics/memory-safety.md>), [union types](<https://devfeed.tech/topics/union-types.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-20](<https://devfeed.tech/tags/c-plus-plus-20.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [c-plus-plus-26](<https://devfeed.tech/tags/c-plus-plus-26.md>), [haskell](<https://devfeed.tech/tags/haskell.md>), [null](<https://devfeed.tech/tags/null.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rust](<https://devfeed.tech/tags/rust.md>), [type-safety](<https://devfeed.tech/tags/type-safety.md>)

### AI overview

This tutorial explains std::optional, a C++17 value type that represents a value that may be absent. It discusses its type safety, memory behavior, and uses such as nullable values, computation results, lazy resource loading, and optional function parameters.

### Source excerpt

Let's take a pair of two types <YourType, bool> - what can you do with such composition? In this article, I'll describe std::optional - a helper "vocabulary" type added in C++17. It's a wrapper that either contains a value of your type or is empty. Let's see where it can be useful and how you can use it. Updated in September 2026 with C++20, C++23, and C++26 changes. Intro By adding the boolean flag to other types, you can achieve a thing called "nullable types". As mentioned, the flag is used to indicate whether the value is available or not. Such wrapper represents an object that might be empty in an expressive way (so not via comments :)) While you can achieve "null-ability" by using unique values (-1, infinity, nullptr), it's not as clear as the separate wrapper type. Alternatively, you could even use std::unique_ptr<Type> and treat the empty pointer as not initialized - this works, but comes with the cost of allocating memory for the object. Optional types - that come from functional programming world - bring type safety and expressiveness. Most of other languages have something similar: for example std::option in Rust, Optional<T> in Java, Data.Maybe in Haskell. std::optional was added in C++17 and brings a lot of experience from boost::optional that was available for many years. Since C++17 you can just #include <optional> and use the type. Such wrapper is still a value type (so you can copy it, via deep copy). What's more, std::optional doesn't need to allocate any memory on the free store. std::optional is a part of C++ vocabulary types along with std::any, std::variant and std::string_view. When to use Usually, you can use an optional wrapper in the following scenarios: If you want to represent a nullable type nicely. Rather than using unique values (like -1, nullptr, NO_VALUE or something) For example, user's middle name is optional. You could assume that an empty string would work here, but knowing if a user entered something or not might be important. W

## San Diego C++ Meetup #87 - July 2026 Edition: Modern Container Filtering, std::span, and a Pause to Rethink

DevFeed: [San Diego C++ Meetup #87 - July 2026 Edition: Modern Container Filtering, std::span, and a Pause to Rethink](<https://devfeed.tech/articles/san-diego-c-meetup-87-july-2026-edition-modern-container-filtering-std-span-and-a-pause-to-rethink-51148.md>)

Original publisher: [Read original article](<https://vorbrodt.blog/2026/08/02/san-diego-c-meetup-87-july-2026-edition-modern-container-filtering-stdspan-and-a-pause-to-rethink/>)

Author: Kobi

Published: 2026-08-02T22:09:12Z

Content type: article

Language: en

Sources: [Vorbrodt's C++ Blog](<https://devfeed.tech/sources/vorbrodt-s-c-blog.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [container](<https://devfeed.tech/topics/container.md>), [Code](<https://devfeed.tech/topics/code.md>), [generators](<https://devfeed.tech/topics/generators.md>), [Promise](<https://devfeed.tech/topics/promise.md>), [execution](<https://devfeed.tech/topics/execution.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [code](<https://devfeed.tech/tags/code.md>), [containers](<https://devfeed.tech/tags/containers.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [cpp](<https://devfeed.tech/tags/cpp.md>), [kobi](<https://devfeed.tech/tags/kobi.md>), [meetup](<https://devfeed.tech/tags/meetup.md>), [recording](<https://devfeed.tech/tags/recording.md>), [san-diego](<https://devfeed.tech/tags/san-diego.md>), [san-diego-c-plus-plus-meetup](<https://devfeed.tech/tags/san-diego-c-plus-plus-meetup.md>), [standard-library](<https://devfeed.tech/tags/standard-library.md>)

### AI overview

A summary of San Diego C++ Meetup #87 covering C++ quiz questions, modern ways to filter container elements, recommendations for C++23 ranges, and coroutine-based generators. It also introduces a discussion of safe buffer passing with std::span.

### Source excerpt

Hello everyone! Here's the summary of our July session, San Diego C++ Meetup #87, held on Tuesday, July 22nd, 2026. As always, if you missed the live session, the recording is up on our YouTube channel (link below once it's shared publicly). You can also find the specific Luma event details for this session right [...]

## How to join or concat ranges, C++26

DevFeed: [How to join or concat ranges, C++26](<https://devfeed.tech/articles/how-to-join-or-concat-ranges-c-26-53313.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2025/join_concat_ranges/>)

Published: 2026-05-16T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Collections](<https://devfeed.tech/topics/collections.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [collections](<https://devfeed.tech/tags/collections.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [lazy](<https://devfeed.tech/tags/lazy.md>)

### AI overview

A tutorial comparing C++ range adaptors for concatenating and flattening collections: concat_view from C++26, join_view from C++20, and join_with_view from C++23. It explains their behavior, supported operations, lazy evaluation, and practical examples.

### Source excerpt

Modern C++ continuously improves its range library to provide more expressive, flexible, and efficient ways to manipulate collections. Usually, when you wanted to concatenate or flatten ranges, you'd use raw loops or custom algorithms. With C++'s range adaptors, we now have an elegant and efficient way to process collections lazily without unnecessary allocations. In this post, we will explore three powerful range adaptors introduced in different C++ standards: std::ranges::concat_view (C++26) std::ranges::join_view (C++20) std::ranges::join_with_view (C++23) Let's break down their differences, use cases, and examples. Updated in May 2026: added from_range construction options. std::ranges::concat_view (C++26) The concat_view allows you to concatenate multiple independent ranges into a single sequence. Unlike join_view, it does not require a range of ranges-it simply merges the given ranges sequentially while preserving their structure. In short: Takes multiple independent ranges as arguments. Supports random access if all underlying ranges support it. Allows modification if underlying ranges are writable. Lazy evaluation: No additional memory allocations. See the example: #include <print> #include <ranges> #include <vector> #include <array> int main() { std::vector<std::string> v1{"world", "hi"}; std::vector<std::string> v2 { "abc", "xyz" }; std::string arr[]{"one", "two", "three"}; auto v1_rev = v1 | std::views::reverse; auto concat = std::views::concat(v1_rev, v2, arr); concat[0] = "hello"; // access and write for (auto& elem : concat) std::print("{} ", elem); } See at @Compiler Explorer The output: hello world abc xyz one two three The example below shows how to concatenate three ranges, v1 is reversed and then combined with v2 and arr. Notice that we can also access the value at position 0 and update it. And a bit more complex example: #include <print> #include <ranges> #include <vector> #include <list> #include <string> struct Transaction { std::string type; d

## 15 Different Ways to Filter Containers in Modern C++

DevFeed: [15 Different Ways to Filter Containers in Modern C++](<https://devfeed.tech/articles/15-different-ways-to-filter-containers-in-modern-c-53298.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2021/filter-cpp-containers/>)

Published: 2026-05-03T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [Code](<https://devfeed.tech/topics/code.md>), [Library](<https://devfeed.tech/topics/library.md>), [implementation](<https://devfeed.tech/topics/implementation.md>)

Tags: [2025](<https://devfeed.tech/tags/2025.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [article](<https://devfeed.tech/tags/article.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [code](<https://devfeed.tech/tags/code.md>), [library](<https://devfeed.tech/tags/library.md>), [standard-library](<https://devfeed.tech/tags/standard-library.md>)

### AI overview

A tutorial explores multiple ways to implement a filter function for C++ containers, including raw loops, standard-library algorithms, and modern C++ techniques. The article was updated with additional C++23 techniques.

### Source excerpt

Do you know how many ways we can implement a filter function in C++? While the problem is relatively easy to understand - take a container, copy elements that match a predicate, and return a new container - it's good to exercise with the C++ Standard Library and check a few ideas. We can also apply some Modern C++ techniques, including C++23. Let's start! The article was written in 2021 and recently updated in late 2025 to include additional techniques from C++23. Additionally, the text is also republished on the ACCU website: ACCU Overload, 33: 15 Different Ways to Filter Containers in Modern C++. The Problem Statement To be precise, by a filter I mean a function with the following interface: auto Filter(const Container& cont, UnaryPredicate p) {} It takes a container and a predicate, and creates an output container with elements (copies) that satisfy the predicate. We can use it like the following: const std::vector<std::string> vec{ "Hello", "**txt", "World", "error", "warning", "C++", "****" }; auto filtered = Filter(vec, [](auto& elem) { return !elem.starts_with('*'); }); // filtered should have "Hello", "World", "error", "warning", "C++" Writing such a function can be a good exercise with various options and algorithms in the Standard Library. What's more, our function hides internal mechanisms like iterators, so it's more like a range-based version. Let's start with the first option: Good old Raw Loops While it's good to avoid raw loops, they might help us to fully understand the problem. For our filtering problem, we can write the following code: // filter v1 template <typename T, typename Pred> auto FilterRaw(const std::vector<T>& vec, Pred p) { std::vector<T> out; for (auto&& elem : vec) if (p(elem)) out.push_back(elem); return out; } Simple yet very effective. Please note some nice features of this straightforward implementation. The code uses auto return type deduction, so there's no need to write the explicit type (although it could be just std::vector<

## C++ Templates: How to Iterate through std::tuple: C++26 Packs and Expansion Statements

DevFeed: [C++ Templates: How to Iterate through std::tuple: C++26 Packs and Expansion Statements](<https://devfeed.tech/articles/c-templates-how-to-iterate-through-std-tuple-c-26-packs-and-expansion-statements-53317.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2025/tuple-iteration-cpp26/>)

Published: 2025-10-12T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [iteration](<https://devfeed.tech/topics/iteration.md>), [syntax](<https://devfeed.tech/topics/syntax.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [code](<https://devfeed.tech/tags/code.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [templates](<https://devfeed.tech/tags/templates.md>)

### AI overview

A tutorial on C++26 techniques for iterating over and transforming tuples. It explains structured binding packs and expansion statements, showing how they replace older index_sequence and std::apply approaches with simpler compile-time code.

### Source excerpt

In part 1 of this mini-series, we looked at the basics of iterating over a std::tuple using index_sequence and fold expressions. In part 2, we simplified things with std::apply and even created helpers like for_each_tuple and transform_tuple. So far, we used C++ features up to C++20/23... but now, in C++26, we finally get language-level tools that make tuple iteration straightforward and expressive. In this article, we'll explore two new techniques: Structured bindings can introduce a pack - P1061 - turn a tuple into a pack of variables. Expansion statements P1306 - the ultimate "compile-time loop" syntax. Structured binding packs Structured bindings have been around since C++17, but in C++26 they gained the ability to introduce packs. That means you can bind an arbitrary number of elements without spelling each out. For example: auto [head, ...rest] = std::tuple{1, 2, 3, 4}; // head == 1, rest... expands to (2, 3, 4) This feature gives us a way to expand tuples into parameter packs, and once we have a pack, we can use fold expressions and other familiar template techniques. Printing a tuple We can bind all elements of a tuple into a pack and then fold over it: #include <tuple> #include <iostream> #include <utility> template <typename Tuple> void print_tuple(const Tuple& t) { const auto& [...xs] = t; bool first = true; std::cout << "("; ((std::cout << (std::exchange(first, false) ? "" : ", ") << xs), ...); std::cout << ")"; } int main() { print_tuple(std::make_tuple(1, 2.2, "hello")); } See at Compiler Explorer This is a direct replacement for our old index_sequence or std::apply approaches - now written in plain C++26. (Of course, you can easily update it to work with std::print) Transforming a tuple We can also apply a transformation and create a new tuple: template <typename Tuple, typename Fn> auto transform_tuple(const Tuple& t, Fn&& fn) { const auto& [...xs] = t; return std::make_tuple(fn(xs)...); } std::tuple tp{1, 2, 3}; auto doubled = transform_tuple(tp, [](a

## GSoC 2025: Bfloat16 in LLVM libc

DevFeed: [GSoC 2025: Bfloat16 in LLVM libc](<https://devfeed.tech/articles/gsoc-2025-bfloat16-in-llvm-libc-43123.md>)

Original publisher: [Read original article](<https://blog.llvm.org/posts/2025-09-10-bfloat16-in-llvm-libc/>)

Author: Krishna Pandey

Published: 2025-09-29T00:00:00Z

Content type: article

Language: en

Sources: [LLVM Project](<https://devfeed.tech/sources/the-llvm-project-blog.md>)

Topics: [LLVM](<https://devfeed.tech/topics/llvm.md>), [floating-point](<https://devfeed.tech/topics/floating-point.md>), [Hardware](<https://devfeed.tech/topics/hardware.md>), [Jule](<https://devfeed.tech/topics/jule.md>)

Tags: [2025](<https://devfeed.tech/tags/2025.md>), [arm](<https://devfeed.tech/tags/arm.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [floating-point](<https://devfeed.tech/tags/floating-point.md>), [gsoc](<https://devfeed.tech/tags/gsoc.md>), [hardware](<https://devfeed.tech/tags/hardware.md>), [libc](<https://devfeed.tech/tags/libc.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [math](<https://devfeed.tech/tags/math.md>), [risc-v](<https://devfeed.tech/tags/risc-v.md>), [x86](<https://devfeed.tech/tags/x86.md>)

### AI overview

This article describes a GSoC project that added BFloat16 support to LLVM libc. It covers the type, generic correctly rounded math functions, supported architectures, additional comparison and higher math functions, limitations, and planned work.

### Source excerpt

Introduction BFloat16 is a 16-bit floating-point format, introduced by Google and standardized in C++23 as std::bfloat16_t. It uses 1 sign bit, 8 exponent bits (the same as float), and 7 mantissa bits. This configuration allows BFloat16 to represent a much wider dynamic range than IEEE binary16 (~3x10^38 values compared to 65,504), though with lower precision. BFloat16 has become popular in AI and machine learning use-cases where it offers significant performance advantages over IEEE binary32 while preserving its approximate dynamic range. The goal of this project was to implement the BFloat16 type in LLVM libc along with the basic math functions like fabsbf16, fmaxbf16, etc. We also want all functions to be generic (platform-independent) and correctly rounded for all rounding modes. What was done BFloat16 type was added to LLVM libc (libc/src/__support/FPUtil/bfloat16.h) #144463. All 70 expected basic math functions for bfloat16 were implemented, using a generic approach that supports all libc supported architectures (ARM, RISC-V, GPUs, x86, Darwin) (see table below). Implemented two additional basic math functions: iscanonicalbf16 and issignalingbf16. Implemented higher math functions: sqrtbf16 #156654 and log_bf16 #157811 (open). Comparison operations for the FPBits class were added #144983. Basic Math FunctionPRfabsbf16#148398ceilbf16, floorbf16, roundbf16, roundevenbf16, truncbf16#152352bf16add, bf16addf, bf16addl, bf16addf128, bf16sub, bf16subf, bf16subl, bf16subf128#152774fmaxbf16, fminbf16#152782bf16mul, bf16mulf, bf16mull, bf16mulf128#152847fmaximumbf16, fmaximum_magbf16, fmaximum_mag_numbf16, fmaximum_numbf16, fminimumbf16, fminimum_magbf16, fminimum_mag_numbf16, fminimum_numbf16#152881bf16div, bf16divf, bf16divl, bf16divf128#153191bf16fma, bf16fmaf, bf16fmal, bf16fmaf128#153231llrintbf16, llroundbf16, lrintbf16, lroundbf16, nearbyintbf16, rintbf16#153882fromfpbf16, fromfpxbf16, ufromfpbf16, ufromfpxbf16#153992nextafterbf16, nextdownbf16, nexttowardbf16, n

## How to Split Ranges in C++23

DevFeed: [How to Split Ranges in C++23](<https://devfeed.tech/articles/how-to-split-ranges-in-c-23-53314.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2025/ranges_split_chunk/>)

Published: 2025-05-16T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [how-to](<https://devfeed.tech/tags/how-to.md>)

### AI overview

A practical tutorial on splitting and grouping ranges in C++ using the C++20 views::split and views::lazy_split adaptors, plus the C++23 views::chunk and views::chunk_by adaptors. It explains range requirements and demonstrates text, generic-range, stream, fixed-size batch, packet, parity, and sentence-processing examples.

### Source excerpt

In this blog post, we'll continue looking at ranges and this time explore ways to split them into sub-ranges. So we'll take a look at views::split, views::chunk, and views::chunk_by. We'll walk through two examples for each adaptor: one simple and one slightly more advanced, to highlight their practical uses. Let's go. Splitting Ranges with views::split, C++20 If you want to split a range using some "delimeter," then views::split (or ranges::split_view) will do the job. template< ranges::forward_range V, ranges::forward_range Pattern > // .. requires... class split_vie : public ranges::view_interface<split_view<V, Pattern>> Both of the ranges V and Pattern have to be forward_range. Notice that you need to use a pattern; it cannot be a condition. Example 1: Splitting a Sentence into Words #include <print> #include <ranges> #include <string_view> int main() { using namespace std::string_view_literals; constexpr auto text = "C++ is powerful and elegant"sv; for (auto part : std::views::split(text, ' ')) std::print("'{}' ", std::string_view(part)); } Play @Compiler Explorer The output: 'C++' 'is' 'powerful' 'and' 'elegant' A classic example that splits a sentence into words. We convert each subrange to std::string_view for easy printing. We can also extend this and use not just one character: constexpr auto text = "C++breakisbreakpowerfulbreakandbreakelegant"sv; for (auto part : std::views::split(text, "break"sv)) std::print("'{}' ", std::string_view(part)); Example 2: Splitting Not Just Text split can be applied to any forward range, so not just text: #include <print> #include <ranges> #include <vector> #include <utility> int main() { using Point = std::pair<int, int>; std::vector<Point> path = { {0, 0}, {1, 1}, {-1, -1}, // marker: {-1, -1} {2, 2}, {3, 3}, {-1, -1}, {4, 4}, {5, 5} }; for (auto segment : std::views::split(path, Point{-1, -1})) std::print("Segment: {}\n", segment); } See @Compiler Explorer And the output: Segment: [(0, 0), (1, 1)] Segment: [(2, 2), (3, 3

## Details of std::mdspan from C++23

DevFeed: [Details of std::mdspan from C++23](<https://devfeed.tech/articles/details-of-std-mdspan-from-c-23-53309.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2025/cpp23_mdspan/>)

Published: 2025-02-27T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [layout](<https://devfeed.tech/topics/layout.md>), [data](<https://devfeed.tech/topics/data.md>), [object](<https://devfeed.tech/topics/object.md>), [constructor](<https://devfeed.tech/topics/constructor.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [data](<https://devfeed.tech/tags/data.md>), [details](<https://devfeed.tech/tags/details.md>), [layout](<https://devfeed.tech/tags/layout.md>)

### AI overview

This tutorial explains C++23's std::mdspan, a multidimensional data view. It covers its declaration, static and dynamic extents, construction options, object size, and layout policies, with notes on related C++26 additions.

### Source excerpt

In this article, we'll see details of std::mdspan, a new view type tailored to multidimensional data. We'll go through type declaration, creation techniques, and options to customize the internal functionality. Type declaration The type is declared in the following way: template< class T, class Extents, class LayoutPolicy = std::layout_right, class AccessorPolicy = std::default_accessor<T> > class mdspan; And it has its own header <mdspan>. The main proposal for this feature can be found at https://wg21.link/P0009 Following the pattern from std::span, we have a few options to create mdspan: with dynamic or static extent. The key difference is that rather than just one dimension, we can specify multiple. The declaration also gives more options in the form of LayoutPolicy and AccessorPolicy. More on that later. Static Extent std::vector<int> vec = {1, 2, 3, 2, 4, 5, 3, 5, 6, 7, 8, 9}; std::mdspan<int, std::extents<size_t, 3, 3>> mat3x3 { vec.data() }; std::print("sizeof: {}, rank: {}, ext 0: {}, ext 1: {}\n", sizeof(mat3x3), mat3x3.rank(), mat3x3.extent(0), mat3x3.extent(1)); The output: sizeof: 8, rank: 2, ext 0: 3, ext 1: 3 Run @Compiler Explorer Dynamic Extent And the dynamic option: std::mdspan<int, std::dextents<size_t, 2>> mat2x2 { vec.data(), 2, 2 }; std::print("sizeof: {}, rank: {}, ext 0: {}, ext 1: {}\n", sizeof(mat2x2), mat2x2.rank(), mat2x2.extent(0), mat2x2.extent(1)); The output: sizeof: 24, rank: 2, ext 0: 2, ext 1: 2 Run @Compiler Explorer The line: std::mdspan<int, std::dextents<size_t, 2>> Is equivalent: std::mdspan<int, std::extents<size_t, std::dynamic_extents, std::dynamic_extents>> In other words, dextents stands for dynamic extents. And as of C++26, we can also simplify it with std::dims: std::mdspan<int, std::dims<2>> mat2x2 { vec.data(), 2, 2 }; Sizeof mdspan As you can see, similarly to std::span, when the size is known at compile time, the object can be smaller (it doesn't have to store the dynamic size). Run here: @Compiler Explorer Constru

## Adjacency Matrix and std::mdspan, C++23

DevFeed: [Adjacency Matrix and std::mdspan, C++23](<https://devfeed.tech/articles/adjacency-matrix-and-std-mdspan-c-23-53310.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2025/cpp23_mdspan_adj/>)

Published: 2025-02-11T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [Graphs](<https://devfeed.tech/topics/graphs.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>), [Code](<https://devfeed.tech/topics/code.md>), [Matrix](<https://devfeed.tech/topics/matrix-org.md>), [Mathematics](<https://devfeed.tech/topics/mathematics.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [return](<https://devfeed.tech/topics/return.md>)

Tags: [adjacency-matrix](<https://devfeed.tech/tags/adjacency-matrix.md>), [array](<https://devfeed.tech/tags/array.md>), [arrays](<https://devfeed.tech/tags/arrays.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [code](<https://devfeed.tech/tags/code.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [efficiency](<https://devfeed.tech/tags/efficiency.md>), [fragmentation](<https://devfeed.tech/tags/fragmentation.md>), [graph](<https://devfeed.tech/tags/graph.md>), [graph-theory](<https://devfeed.tech/tags/graph-theory.md>), [graphs](<https://devfeed.tech/tags/graphs.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [locality](<https://devfeed.tech/tags/locality.md>), [matrix](<https://devfeed.tech/tags/matrix.md>), [overhead](<https://devfeed.tech/tags/overhead.md>), [vector](<https://devfeed.tech/tags/vector.md>)

### AI overview

A tutorial on implementing adjacency matrices for undirected weighted graphs in C++23. It compares nested vectors with a contiguous vector and then introduces std::mdspan as a non-owning multidimensional view to simplify indexing and improve memory locality.

### Source excerpt

In graph theory, an adjacency matrix is a square matrix used to represent a finite (and usually dense) graph. The elements of the matrix indicate whether pairs of vertices are adjacent or not, and in weighted graphs, they store the edge weights. In many beginner-level tutorials, adjacency matrices are implemented using vector of vectors (nested dynamic arrays), but this approach has inefficiencies due to multiple memory allocations. C++23 introduces std::mdspan, which provides a more efficient way to handle multidimensional data structures without the overhead of nested containers. In this blog post, we'll explore various implementations of an adjacency matrix, starting with a basic approach and progressively improving it using std::mdspan. Starting slow Let's start with a straightforward implementation using a vector of vectors to represent the adjacency matrix. #include <iostream> #include <vector> #include <limits> #include <print> template <typename T> class Graph { public: static constexpr T INF = std::numeric_limits<T>::max(); private: std::vector<std::vector<T>> adjacencyMatrix; size_t numVertices; public: Graph(size_t vertices) : numVertices(vertices) , adjacencyMatrix(vertices, std::vector<T>(vertices, INF)) { for (size_t i = 0; i < numVertices; i++) adjacencyMatrix[i][i] = 0; } void addEdge(size_t u, size_t v, T weight) { if (u < numVertices && v < numVertices && u != v) { adjacencyMatrix[u][v] = weight; adjacencyMatrix[v][u] = weight; } } bool isConnected(size_t u, size_t v) const { return (u < numVertices && v < numVertices && adjacencyMatrix[u][v] != INF); } const std::vector<std::vector<T>>& getAdjacencyMatrix() const { return adjacencyMatrix; } }; template <typename T> void printGraph(const Graph<T>& g) { std::print("Adjacency Matrix:\n"); for (const auto& row : g.getAdjacencyMatrix()) { for (T weight : row) { if (weight == Graph<T>::INF) std::print(" ∞ "); else std::print(" {:3} ", weight); } std::println(); } } The class represents an undirected wei

## C++23 Library Features and Reference Cards

DevFeed: [C++23 Library Features and Reference Cards](<https://devfeed.tech/articles/c-23-library-features-and-reference-cards-53304.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2024/cpp23_lib/>)

Published: 2024-12-08T00:00:00Z

Content type: article

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Library](<https://devfeed.tech/topics/library.md>), [Code](<https://devfeed.tech/topics/code.md>), [standard](<https://devfeed.tech/topics/standard.md>), [debugging](<https://devfeed.tech/topics/debugging.md>), [toolchain](<https://devfeed.tech/topics/toolchain.md>)

Tags: [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [headers](<https://devfeed.tech/tags/headers.md>), [library](<https://devfeed.tech/tags/library.md>), [reference](<https://devfeed.tech/tags/reference.md>), [standard](<https://devfeed.tech/tags/standard.md>)

### AI overview

A reference guide to C++23 standard library features, covering new headers, stacktrace support, scoped-enum utilities, pointer wrappers, container construction, ranges algorithms, and view additions. It includes short explanations and code examples.

### Source excerpt

In this blog post, you'll see all C++23 library features! Each with a short description and additional code example. Prepare for a ride! For language features please see the previous article: C++23 Language Features and Reference Cards - C++ Stories Want your own copy to print? If you like, I prepared PDF I packed both language and the Standard Library features. Each one has a short description and an example if possible. All of the existing subscribers of my mailing list have already got the new document, so If you want to download it just subscribe here: Download a free copy of C++23 Ref Card! Please notice that along with the new ref card you'll also get C++20 and C++17 language reference card that I initially published three years ago. With this "package" you'll quickly learn about all of the latest parts that Modern C++ acquired over the last few years. New Headers expected flat_map, flat_set generator mdspan print spanstream stacktrace stdfloat Stacktrace Library P0881 Based on Boost.Stacktrace allows for more context when debugging code. The library defines components to store the stacktrace of the current thread of execution and query information about the stored stacktrace at runtime. #include <iostream> #include <stacktrace> void foo() { std::cout << std::stacktrace::current(); } int main() { [] { foo(); }(); } Experiment @Compiler Explorer, note that GCC 14 requires to be linked with -lstdc++exp. Possible output on GCC: 0# foo() at /app/example.cpp:5 1# operator() at /app/example.cpp:10 2# main at /app/example.cpp:11 3# at :0 4# __libc_start_main at :0 5# _start at :0 is_scoped_enum & to_underlying P1048R1 (is_scoped_enum), P1682R3 (to_underlying) #include <print> #include <utility> // for std::to_underlying enum class Color: uint8_t { Red = 1, Green = 2, Blue = 3 }; enum Col { Red, Green, Blue }; int main() { Color c = Color::Blue; // Pre-C++23: verbose casting auto old_way = static_cast<std::underlying_type_t<Color>>(c); // C++23: clean and simple auto

## C++23 Language Features and Reference Cards

DevFeed: [C++23 Language Features and Reference Cards](<https://devfeed.tech/articles/c-23-language-features-and-reference-cards-53303.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2024/cpp23_lang/>)

Published: 2024-11-17T00:00:00Z

Content type: article

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [standard](<https://devfeed.tech/topics/standard.md>)

Tags: [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [code](<https://devfeed.tech/tags/code.md>), [example](<https://devfeed.tech/tags/example.md>), [language](<https://devfeed.tech/tags/language.md>), [reference](<https://devfeed.tech/tags/reference.md>), [standard](<https://devfeed.tech/tags/standard.md>)

### AI overview

A practical overview of C++23 language features, with short descriptions and code examples. It also outlines the standard's development timeline and highlights major additions finalized through 2023.

### Source excerpt

C++23 Language Features In this blog post, you'll see all C++23 language features! Each with short description and additional code example. Prepare for a ride! For library features please see the next article: C++23 Library Features and Reference Cards - C++ Stories Want your own copy to print? If you like, I prepared PDF I packed both language and the Standard Library features. Each one has a short description and an example if possible. All of the existing subscribers of my mailing list have already got the new document, so If you want to download it just subscribe here: Download a free copy of C++23 Ref Card! Please notice that along with the new ref card you'll also get C++20 and C++17 language reference card that I initially published three years ago. With this "package" you'll quickly learn about all of the latest parts that Modern C++ acquired over the last few years. Timeline Here's a short overview about the timeline for the new standard. February 2020 (Prague): Final C++20 meeting where initial plans for C++23 were adopted Key planned features: library support for coroutines, modular standard library, executors, and networking June 2020: First planned WG21 meeting for C++23 in Varna was cancelled due to COVID-19 pandemic November 2020: New York meeting cancelled, moved to virtual format Key additions: size_t literals, stacktrace library, contains() member functions, C atomic interoperability February 2021: Virtual meeting Notable features: Lambda expression simplifications, variant improvements, conditionally borrowed ranges June 2021: Virtual summer plenary meeting Major additions: if consteval, spanstream, out_ptr/inout_ptr, constexpr improvements October 2021: Virtual autumn plenary meeting Significant features: Explicit this parameter, multidimensional subscript operator, zip ranges February 2022: Virtual meeting Key additions: std::expected, ranges::to, windowing range adaptors July 2022: Virtual meeting Major features: static operator(), UTF-8 source

## Around the World in C++: Exploring Time Zones with std::chrono

DevFeed: [Around the World in C++: Exploring Time Zones with std::chrono](<https://devfeed.tech/articles/around-the-world-in-c-exploring-time-zones-with-std-chrono-53306.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2024/zones_around_world_chrono/>)

Published: 2024-11-10T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Library](<https://devfeed.tech/topics/library.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [database](<https://devfeed.tech/tags/database.md>), [library](<https://devfeed.tech/tags/library.md>), [programming](<https://devfeed.tech/tags/programming.md>)

### AI overview

A tutorial on using C++20's std::chrono time-zone support to inspect the IANA Time Zone Database and identify unusual offsets and daylight-saving rules. It examines examples including Nepal's UTC+5:45 offset and Lord Howe Island's 30-minute daylight-saving adjustment.

### Source excerpt

While most time zones use simple hour offsets from UTC, some regions have chosen unusual time differences. In this blog post, we'll explore how we can discover such zones using C++20's chrono library. We'll use GCC 14.2 as it fully supports C++20 chrono and also std::print from C++23. First Attempt: Basic Zone Iteration C++20 introduced comprehensive time zone support through the <chrono> library. The implementation relies on the IANA Time Zone Database (also known as the "tz database" or "zoneinfo"), which is the de facto standard for time zone information used by most operating systems and programming languages. The Time Zone Database In C++20, the time zone database is represented by the tzdb class: namespace std::chrono { struct tzdb { string version; // IANA time zone database version vector<time_zone> zones; // Time zone container vector<time_zone_link> links; // Alternative names vector<leap_second> leap_seconds; // Leap second info }; } Essential aspects of the database: It's read-only - users cannot construct or modify a tzdb Access is provided through two global functions: get_tzdb(): Returns the current database get_tzdb_list(): Returns the list of available database versions Here's how to access the database: #include <chrono> #include <print> #include <cassert> int main() { const auto& db = std::chrono::get_tzdb(); std::print("Current DB version: {}\n", db.version); const auto& db_list = std::chrono::get_tzdb_list(); auto size = std::distance(db_list.begin(), db_list.end()); std::print("Available versions: {}\n", size); assert(&db_list.front() == &db); } See at Compiler Explorer The database provides several key components: Zones (db.zones): Primary container of time zone information Each zone contains complete historical and current rules Examples: "America/New_York", "Europe/London" Links (db.links): Alternative names for existing zones Useful for backward compatibility Example: "EST" links to "America/New_York" Leap Seconds (db.leap_seconds): Records

## What is the current time around the world? Utilizing std::chrono with time zones in C++23

DevFeed: [What is the current time around the world? Utilizing std::chrono with time zones in C++23](<https://devfeed.tech/articles/what-is-the-current-time-around-the-world-utilizing-std-chrono-with-time-zones-in-c-23-53302.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2024/chrono_dates_zones/>)

Published: 2024-11-03T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [DateTime](<https://devfeed.tech/topics/datetime.md>), [Code](<https://devfeed.tech/topics/code.md>), [gcc](<https://devfeed.tech/topics/gcc.md>)

Tags: [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [clock](<https://devfeed.tech/tags/clock.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [formatting](<https://devfeed.tech/tags/formatting.md>), [time](<https://devfeed.tech/tags/time.md>), [utc](<https://devfeed.tech/tags/utc.md>)

### AI overview

This tutorial demonstrates how to use C++20 and C++23 date and time facilities with std::chrono. It covers formatting dates and times, retrieving times in different time zones, handling daylight saving time, and using the IANA time-zone database through operating-system support.

### Source excerpt

In this blog post, we will explore handling dates using std::chrono, including time zones. We'll utilize the latest features of the library to retrieve the current time across various time zones, taking into account daylight saving time changes as well. Additionally, we will incorporate new capabilities introduced in C++23, such as enhanced printing functions and more. Let's start with the following code that prints the current date and time: #include <chrono> #include <print> int main() { auto now = std::chrono::system_clock::now(); std::print("now is {}", now); } You can run it through Compiler Explorer In my session, I'm getting the following results: Now is 2024-11-01 11:44:06.374573703 It's simple, but what time zone are we in? Can we print it in a shorter form? How can we check the time around the world? What about daylight saving time? First things first: time output. Improving the print As you can see, I used std::print from C++23, which is available in GCC 14! By default, the time point obtained from ::now() is printed with full information, but we can change it and adjust it. For example: Basic Date and Time Formatting Show just the date: {0:%F} will format the date as YYYY-MM-DD. Show time in hh:mm:ss format: {0:%T} will format the time as HH:MM:SS. Show the name of the month and/or day of the week: {0:%A, %B} will format it as Day, Month. Advanced Formatting Options Year and Month: {0:%Y}: Full year (e.g., 2024). {0:%y}: Last two digits of the year (e.g., 24). {0:%B}: Full month name (e.g., November). {0:%b}: Abbreviated month name (e.g., Nov). Day and Week: {0:%d}: Day of the month, zero-padded (e.g., 01). {0:%A}: Full weekday name (e.g., Friday). {0:%a}: Abbreviated weekday name (e.g., Fri). Time of Day: {0:%H}: Hour (24-hour clock), zero-padded (e.g., 14). {0:%I}: Hour (12-hour clock), zero-padded (e.g., 02). {0:%M}: Minute, zero-padded (e.g., 05). {0:%S}: Second, zero-padded (e.g., 09). {0:%p}: AM/PM designation. Time Zone: {0:%Z}: Time zone abbrevia

## C++ String Conversion: Exploring std::from\_chars in C++17 to C++26

DevFeed: [C++ String Conversion: Exploring std::from\_chars in C++17 to C++26](<https://devfeed.tech/articles/c-string-conversion-exploring-std-from-chars-in-c-17-to-c-26-53297.md>)

Original publisher: [Read original article](<https://www.cppstories.com/2018/12/fromchars/>)

Published: 2024-10-13T00:00:00Z

Content type: tutorial

Language: en

Sources: [C++ Stories](<https://devfeed.tech/sources/c-stories.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [API](<https://devfeed.tech/topics/api.md>), [Error Handling](<https://devfeed.tech/topics/error-handling.md>), [standard](<https://devfeed.tech/topics/standard.md>), [Memory Safety](<https://devfeed.tech/topics/memory-safety.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [c-plus-plus-23](<https://devfeed.tech/tags/c-plus-plus-23.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [error-reporting](<https://devfeed.tech/tags/error-reporting.md>), [memory-safety](<https://devfeed.tech/tags/memory-safety.md>), [performance](<https://devfeed.tech/tags/performance.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>)

### AI overview

A tutorial on std::from_chars, the C++17 Standard Library API for converting character sequences to numeric values. It compares the low-level, non-throwing and non-allocating API with older conversion methods, and discusses constexpr support, performance, and error handling through C++26.

### Source excerpt

With the introduction of C++17, the C++ Standard Library expanded its capabilities for converting text to numbers with the addition of std::from_chars. This low-level, high-performance API offers significant advantages over previous methods, such as atoi and stringstream. In this article, we will explore the evolution of string conversion routines from C++17 through C++26, highlighting key improvements like constexpr support and enhanced error handling. Let's dive into the details and see how std::from_chars can transform your approach to string conversion. Updated in Oct 2024: Added notes from constexpr support in C++23, and C++26 improvements, plus more Compiler Explorer examples. Before C++17 C++, before C++17, offered several options when it comes to string conversion: sprintf / snprintf sscanf atol strtol strstream stringstream to_string stoi and similar functions And with C++17 you get another option: std::from_chars! Wasn't the old stuff good enough? Why do we need new methods? In short: because from_chars is low-level, and offers the best possible performance. The new conversion routines are: non-throwing non-allocating no locale support memory safety error reporting gives additional information about the conversion outcome The API might not be the most friendly to use, but it's easy enough to wrap it into some facade. A simple example: const std::string str { "12345678901234" }; int value = 0; std::from_chars(str.data(),str.data() + str.size(), value); // error checking ommited... The Series This article is part of my series about C++17 Library Utilities. Here's the list of the topics in the series: Refactoring with std::optional Using std::optional Error handling and std::optional Everything You Need to Know About std::variant from C++17 Everything You Need to Know About std::any from C++17 std::string_view Performance and followup C++17 string searchers and followup Conversion utilities: on std::from_chars - from a string to a number and on std::to_chars