r/cpp • • Apr 28 '26

boost::container::hub ACCEPTED into Boost

69 Upvotes

Hi to all, I'm glad to announce that the proposed boost::container::hub container has been ACCEPTED. Congrats u/joaquintides !

More details here:

https://lists.boost.org/archives/list/boost@lists.boost.org/thread/7WZ7QTPE2YDYD5OYCKXKKV2N74JHJRZL/

Reminder:

hub is a sequence container with O(1) insertion and erasure and element stability with great performance (see these benchmarks): pointers/iterators to an element remain valid as long as the element is not erased. hub is very similar but not entirely equivalent to C++26 std::hive (hence the different naming, consult the section "Comparison with std::hive" for details).


r/cpp • • Apr 28 '26

Things C++26 define_static_array can’t do

Thumbnail quuxplusone.github.io
43 Upvotes

r/cpp • • Apr 28 '26

New features in GCC 16: Improved error messages and SARIF output

Thumbnail developers.redhat.com
114 Upvotes

r/cpp • • Apr 27 '26

The fastest Linux timestamps

Thumbnail hmpcabral.com
58 Upvotes

r/cpp • • Apr 27 '26

Florent Castelli: Introduction to the Bazel build system

Thumbnail youtu.be
61 Upvotes

An introduction to Bazel, the open-source build system designed to make C++ development fast, deterministic, and scalable for any team size.


r/cpp • • Apr 27 '26

New C++ Conference Videos Released This Month - April 2026 (Updated To Include Videos Released 2026-04-20 - 2026-04-26)

15 Upvotes

CppCon

2026-04-20 - 2026-04-26

2026-04-13 - 2026-04-19

2026-04-06 - 2026-04-12

2026-03-30 - 2026-04-05

C++Online

2026-04-20 - 2026-04-26

2026-04-13 - 2026-04-19

2026-04-06 - 2026-04-12

2026-03-30 - 2026-04-05

ADC

2026-04-20 - 2026-04-26

2026-04-13 - 2026-04-19

2026-04-06 - 2026-04-12

2026-03-30 - 2026-04-05

Meeting C++

2026-04-06 - 2026-04-12

2026-03-30 - 2026-04-05

using std::cpp

2026-03-30 - 2026-04-05


r/cpp • • Apr 26 '26

The Hidden Performance Price of C++ Virtual Functions

Thumbnail youtube.com
61 Upvotes

At the online weekend series by Global C++, Ivica from https://johnnysswlab.com/ explains, with examples, what the actual cost of using virtual functions in current C++ with modern hardware actually is.


r/cpp • • Apr 26 '26

I made my C++ vector search engine 16x faster by changing data layout, not the algorithm

Thumbnail dubeykartikay.com
120 Upvotes

I’m working on a small vector search engine in C++ and spent some time cleaning up the Vamana search path.

The big win came from getting rid of a pointer-heavy layout and moving to flatter arrays / lighter-weight views. Same algorithm and recall, but much lower query latency in my benchmark.


r/cpp • • Apr 26 '26

"Parse, don't Validate" through the years with C++

Thumbnail derekrodriguez.dev
55 Upvotes

It's been a few years since I worked with C++ on a day-to-day basis in a professional capacity, but I like writing blog posts every now and then, and thought I would put my own spin on the evergreen "Parse, don't validate", by Alexis King. Feedback is welcome!


r/cpp • • Apr 26 '26

Is there a C++ "venv" equivalent?

105 Upvotes

Python have venv, Rust have cargo, Node have nvm. You clone a repo, run one command, you're in a reproducible environment.

Is there a viable alternative for C++? I don't think standard will ever bother with this and to their defence, not sure if that is even possible.

I've tried Conan, vcpkg, various CMake setups. They're not bad tools, but there's no standard "activation" ritual. No isolated-per-project environment that pins compiler + deps + toolchain together. No single lockfile that means the same thing on my machine, my colleague's machine, and CI. What I keep wanting is something like: "cppenv activate" and suddenly I'm in a clean, isolated, reproducible build environment for that project. Exit it, and my system is untouched. Share a lockfile, and a teammate gets the exact same thing.

How are you handling reproducible build/development environments?


r/cpp • • Apr 26 '26

Code Examples From an App Using C++ Modules

Thumbnail abuehl.github.io
16 Upvotes

This demonstrates usage of our recommendations for using modules:

  • Prefer small modules
  • Only use partitions if you really must
  • Avoid using internal partitions

The intention is to show some real code for context of discussions about using C++ modules.

My goal is not to sell modules. If you prefer not using modules: Use header files. There are good reasons to continue using them.

For me, C++ source code is an asset. The intrinsic value of code using modules is higher (lower entropy), as modules are a higher abstraction, compared to header files, which are basically just the pasting of C++ code into translation units (I've done that for ~36 years now).

Using C++ modules comes at a cost though. Understanding modules requires a certain level of understanding, which isn't needed when using the simple model and tradition of header files.


r/cpp • • Apr 26 '26

How To Write PyTorch C++ Extensions in 2026

Thumbnail youtube.com
8 Upvotes

r/cpp • • Apr 25 '26

Using Reflection For Parsing Command Line Arguments

128 Upvotes

I've been very excited about reflection so I built a small library to pass command line arguments

Basic example:

struct Args
{
    std::string first_name;
    int age;
    bool active;
};

// ./program --first-name John --age 99 --active

const auto args = clap::parse<Args>(argc, argv);

assert(args.first_name == "John");
assert(args.age == 99);
assert(args.active);

More interesting example:

struct Args
{
    [[= clap::Description<"host to connect to">{}]]
    std::string host = "localhost";

    [[=clap::ShortName<'p'>{}]]
    std::uint16_t port;

    [[=clap::Env<"RETRY_COUNT">{}]]
    std::uint32_t retry_count;

    std::optional<std::string> log_file;

    [[=clap::ShortName<'e'>{}]]
    bool encrypted;

    [[=clap::ShortName<'c'>{}]]
    bool compressed;

    [[=clap::ShortName<'h'>{}]]
    bool hashed;
};

// ./program -p 8080 -ec

const auto args = clap::parse<Args>(argc, argv);

assert(args.host == "localhost");
assert(args.port == 8080);
assert(args.retry_count == std::stoul(std::getenv("RETRY_COUNT")));
assert(!args.log_file);
assert(args.encrypted);
assert(args.compressed);
assert(!args.hashed);

The amount of code to handle this is actually quite minimal < 500 lines.

There's a few modern goodies that make this code work:

I guess we don't know what "idiomatic" reflection usage is like yet, I'm interested to come back to this code in a years time and see what mistakes I made!

Link to the code: https://github.com/nathan-baggs/clap

Any feedback, queries, questions are welcome!


r/cpp • • Apr 25 '26

Interview with Guy Davidson - the new ISO C++ convener

Thumbnail youtube.com
25 Upvotes

r/cpp • • Apr 25 '26

Defending against exceptions in a scope_exit RAII type

Thumbnail devblogs.microsoft.com
36 Upvotes

r/cpp • • Apr 25 '26

StockholmCpp 0x3D: Intro, Eventhost, Info and the C++ Quiz

Thumbnail youtu.be
9 Upvotes

The intro of the most recent Stockholm Cpp Meetup, with a short overview of what NetInsight develops with C++, some news about C++, and the C++ Quiz


r/cpp • • Apr 24 '26

CppCast CppCast Looking for Guests

86 Upvotes

As you may be aware - I've restarted CppCast (every 4th week in a rhythm with C++Weekly) with u/mropert as my cohost.

We are trying to focus on new people and projects who have never before been on CppCast. I have been trolling the show and tell posts here for potential guests and projects.

But I want to ask directly - if you are interested in coming on the podcast to talk about your project / presentation / things you are passionate about and have never before been on CppCast, please comment!

A couple of notes:

  • please don't be offended if I don't respond to your post, I have a very busy travel and conference schedule coming up (I'll see you at an upcoming conference!)
  • if you're interested please pay attention for a DM so we can get the conversation started.
  • being only 1 podcast per month, we don't need a ton of guests, and it might be a few months before your specific interview gets aired

Thank you everyone!


r/cpp • • Apr 24 '26

Parallel C++ for Scientific Applications: Integrating C++ and Python

Thumbnail youtube.com
21 Upvotes

In this week’s lecture, Dr. Hartmut Kaiser focuses on the seamless integration of C++ and Python. The lecture highlights essential foundational concepts by exploring how to combine the user-friendliness and extensive library ecosystem of Python with the raw performance of C++, setting the stage for highly efficient scientific computing.
A core discussion demonstrates how to utilize the Pybind11 library as a lightweight solution for creating Python bindings, specifically addressing the practical challenges of mapping C++ functions, classes, and diverse data types. Finally, critical strategies for integrating NumPy arrays are explored, offering a comprehensive approach to maximizing performance in advanced mathematical and data-driven applications.
If you want to keep up with more news from the Stellar group and watch the lectures of Parallel C++ for Scientific Applications and these tutorials a week earlier please follow our page on LinkedIn https://www.linkedin.com/company/ste-ar-group/
Also, you can find our GitHub page below:
https://github.com/TheHPXProject/hpx


r/cpp • • Apr 24 '26

C++26: Structured Bindings can introduce a Pack

Thumbnail sandordargo.com
101 Upvotes

r/cpp • • Apr 25 '26

C++ Modules: clangd, go or no go debating on pulling the modules plug on a project

0 Upvotes

Every now and then, someone asks how C++ modules are going. I am a lead dev (mentioned not for bragging but to emphasize the crushing weight of responsibility) for a robotics project, as we are making a CV codebase from scratch, I have the opportunity to choose the architecture and conventions of the code (even more crushing responsibility).

I have gotten some C++23 codebases with modules set up; however, whenever adding a new module, I have to recompile to get clangd to not spam extra errors. I have been starting to get second thoughts with pushing modules all the way. To avoid the gcc-clangd stuff, I ended up specifying the compiler as clang (although I could use clangd compiler flag remove/add).

The codebase is at a point where I can relatively, easily pull the plug on modules.

Requirements:

  1. No vscode or intellisense - I'm tired of vendor lock
  2. Clangd, so we have neovim-coc-clangd + vscodium support
  3. Sits well with cmake
  4. Not really has to sit too well with clangd, as long as it sits well with compile_commands.json since that is a bit more of a decentralized standard for code completion etc.
  5. As much as I would be willing to learn to code without code completion, I would prefer to have enough leeway to radicalize newbies to a nvim plugin with vscodium or neovim-coc-clangd + telescope itself ^_^

Ideals:

  1. Codebase can work with as many compilers as possible (as long as they support #pragma once because the time spent on botched header guards + incoming newbies concerns me enough to diverge a lil' bit from standard C++. Also, our CV codebase is one of those projects that isn't meant to be portable. All of our portable code does use header guards to please the great bjorne stroustroup
  2. Ease with other code completion tools

Why (for the curious):

  1. Vendor lock sucks
  2. Proprietary vendor lock sucks even more
  3. I have a bone to pick with microslop
  4. Because as an embedded project, vscode's oddities disrupts portions of our toolchain from time to time
  5. Even though the CV codebase is not embedded, the fact that vscode support for modules was much harder to get than neovim/clangd just left a bad taste in my mouth. Call me unskilled, but it convinced the newer devs to learn modern C++ on pure command line rather than a shiny GUI-based IDE setup :P

For the curiouser: no, we don't use github anymore :P


r/cpp • • Apr 24 '26

Hunting a Windows ARM crash through Rust, C, and a Build-System configurations

Thumbnail autoexplore.medium.com
12 Upvotes

This week I experienced really interesting bug hunt where Windows ARM target platform started failing CI while other environments passed successfully.

I learnt how to:

  • Use C - programs from Rust programs
  • Compiler configurations are as important as source code
  • What is STATUS_ACCESS_VIOLATION

Hope you like it :)


r/cpp • • Apr 23 '26

Devirtualization and Static Polymorphism

Thumbnail david.alvarezrosa.com
81 Upvotes

r/cpp • • Apr 23 '26

Boost.Decimal: IEEE 754 Decimal Floating Point for C++ — Header-Only, Constexpr, C++14

Thumbnail boost.org
90 Upvotes

Boost 1.91 ships a new library: Boost.Decimal, a full implementation of IEEE 754 and ISO/IEC DTR 24733 decimal floating point types. Authors are Matt Borland and Chris Kormanyos.

The problem it solves

Binary floating point stores significands in base-2. This means values like 0.1 can't be represented exactly, which is why 0.1 + 0.2 != 0.3 in every language that uses IEEE 754 binary FP. Decimal floating point stores significands in base-10, eliminating these representation errors entirely. If you've ever used integer arithmetic or fixed point to avoid rounding issues in financial code, this is the general purpose alternative.

What you get

Six types across two families. The IEEE-conformant types, decimal32_t, decimal64_t, decimal128_t, give you strict standards compliance. The non-IEEE fast variants, decimal_fast32_t, decimal_fast64_t, decimal_fast128_t, trade strict conformance for throughput, and benchmark significantly faster (often 2–3x over the IEEE types for basic arithmetic).

Nearly everything is constexpr, thanks to a deliberate design decision to target C++14's relaxed constexpr rather than support floating point exception flags. The library treats decimal types as close to built in types as possible.

Standard library surface coverage is extensive: <cmath> (trig, exp, power, error/gamma, special functions), <charconv> (to/from_chars), <format> and {fmt}, <cfenv> rounding modes, <cfloat> eval modes, <cstdio> printf, <functional> hash, <limits> numeric_limits, and <string> to_string. Boost.Math integration works out of the box, giving you statistics, interpolation, and quadrature on decimal types for free.

Performance

This is software FP competing against hardware-accelerated binary FP, so basic arithmetic is naturally slower, typically 10–30x vs double for the IEEE types, and 4–15x for the fast types. But <charconv> is where things get interesting: from_chars for decimal32_t runs at roughly 1.2× vs double on Linux, and on MSVC it's actually ~5× faster than double. to_chars in scientific format at 6-digit precision comes in under double across all platforms. The fast types also consistently outperform Intel's libbid and GCC's _Decimal types in most benchmarks.

Practical details

Header only, no dependencies, requires C++14. Tested on x86_64, ARM64 (including Apple Silicon), s390x, PPC64LE, and ARM Cortex-M (via QEMU). Compiler support: GCC 8+, Clang 6+, MSVC 2019+, Intel oneAPI DPC++.

One design trade off worth noting: <cmath> functions are not correctly rounded in the IEEE 754 sense (0.5 ULP). This matches real-world behavior from Intel's own libdfp, and is consistent with how binary FP math libraries work in practice. The authors chose constexpr support over FP exception flags, which seems like the right call for a modern C++ library.

Docs: https://boost.org/libs/decimal

Benchmarks: https://boost.org/doc/libs/latest/libs/decimal/doc/html/benchmarks.html

Happy to answer questions. We would be interested to hear from anyone doing financial or embedded work on whether this changes how you'd approach precision sensitive code.


r/cpp • • Apr 23 '26

Libraries for general purpose 2D/3D geometry vocabulary types?

24 Upvotes

I work in the geospatial industry and have worked on plenty of large projects that have their own internal geometry libraries. Some good, some bad, most with interesting historical choices. I recently joined a new project that hasn't yet really defined its vocabulary types yet, and I'm finding that extremely inconvenient, so I'm looking around at what is common

The kinds of things I'm looking for are:

  • Vector<typename T, size_t Dimension>: Basically a std::array<T,Dimension> with a vector-like API
  • Point: A wrapper around a Vector with point semantics
  • Size: A wrapper around a Vector with size semantics
  • Range: A basic min/max interval
  • AxisAlignedBox: A set of Ranges in N dimensions
  • RotatedBox: A AxisAlignedBox with a basis Vector
  • Polyline: A std::vector<Point> assumed to be open
  • Polygon: A std::vector<Point> assumed to be closed
  • Matrix: An NxM matrix
  • ...

I know there are plenty of vector/matrix/linear algebra libraries out there, often focused on flexibilty and raw computational performance. I'm more interested in nice vocabulary types that implement proper semantics via convenient methods and operators.

It seems these things are often provided by game engines, but pulling in an entire game engine for a non-gaming project feels silly.

So if you were starting a new, greenfield C++ application dealing with 3D geometric data, which existing library, if any, would you reach for?