r_cpp | Unsorted

Telegram-канал r_cpp - C++ - Reddit

-

Stay up-to-date with everything C++! Content directly fetched from the subreddit just for you. Join our group for discussions : @programminginc Powered by : @r_channels

Subscribe to a channel

C++ - Reddit

Triggering a silent Windows Factory Reset via C++: Reverse engineering the undocumented ResetEngine.dll

Hi r/cpp,

I wanted to share a project I've been working on. I needed a way to trigger a complete Windows factory reset (Push Button Reset) programmatically with zero UI overhead. Normally, this is done via SystemSettings.exe or WMI classes like MDM_RemoteWipe (which often require active MDM enrollment).

Instead of relying on those, I decided to interact directly with the underlying undocumented API: ResetEngine.dll.

I built a C++ tool that bypasses the standard UI and forces the system into the Windows Recovery Environment (WinRE) to format the partition.

The C++ Implementation: Since the API is undocumented, the code relies on dynamically loading the DLL (LoadLibraryW) and mapping function pointers (GetProcAddress) for the internal engine functions. The sequence looks like this:

1. ResetCreateSession: Initializes a session targeting the C: drive.
2. ResetPrepareSession: Configures the parameters. I pass scenarioType = 1 to force the "Remove Everything" wipe.
3. ResetStageOfflineBoot: Modifies the BCD to boot directly into WinRE, avoiding the need to manually configure ArmBootTrigger.
4. InitiateSystemShutdownExW: Triggers the reboot to let WinRE take over.

The tool requires SYSTEM privileges (easily tested via psexec -s) to successfully hook into the engine.

Repository: https://github.com/arielmendoza/Windows-factory-reset-tool

Disclaimer: If you compile and run this with the --force flag as SYSTEM, it WILL wipe your machine immediately with no confirmation. Please test in a VM.

I’d love to get your feedback on the code structure, the way the undocumented functions are handled, or if anyone here has explored the other scenario types exposed by this DLL.

https://redd.it/1rs2cir
@r_cpp

Читать полностью…

C++ - Reddit

I feel concerned about my AI usage.

I think use of AI affects my critical thinking skills.

Let me start with doc and conversions, when I write something it is unrefined, instead of thinking about how to write it nicer my brain shuts down, and I feel the urge to just let a model edit it.

A model usually makes it nicer, but the flow and the meaning and the emotion it contains changes.
Like everything I wrote was written by someone else in an emotional state I can't relate.

Same goes for writing code, I know the data flow, libraries use etc. But I just can't resist the urge to load the library public headers to an AI model instead of reading extremely poorly documented slop.

Writing software is usually a feedback loop, but with our fragmented and hyper individualistic world, often a LLM is the only positive source of feedback. It is very rare to find people to collaborate on something.

I really do not know what to do about it, my station and what I need to demands AI usage, otherwise I can't finish my objectives fast enough.

Like software is supposed to designed and written very slow, usually it is a very complicated affair, you have very elaborate documentation, testing, sanitisers tooling etc etc.

But somehow it is now expected that you should write a new project in a day or smth. I really feel so weird about this.


https://redd.it/1rrrh3e
@r_cpp

Читать полностью…

C++ - Reddit

Glaze 7.2 - C++26 Reflection | YAML, CBOR, MessagePack, TOML and more

[Glaze](https://github.com/stephenberry/glaze) is a high-performance C++23 serialization library with compile-time reflection. It has grown to support many more formats and features, and in v7.2.0 C++26 Reflection support has been merged!

GitHub: [https://github.com/stephenberry/glaze](https://github.com/stephenberry/glaze) | [Docs](https://stephenberry.github.io/glaze/)

# C++26 Reflection (P2996)

Glaze now supports C++26 reflection with experimental GCC and Clang compilers. GCC 16 will soon be released with this support. When enabled, Glaze replaces the traditional `__PRETTY_FUNCTION__` parsing and structured binding tricks with proper compile-time reflection primitives (`std::meta`).

The API doesn't change at all. You just get much more powerful automatic reflection that still works with Glaze overrides! Glaze was designed with automatic reflection in mind and still lets you customize reflection metadata using `glz::meta` on top of what `std::meta` provides via defaults.

# What C++26 unlocks

* **Unlimited struct members** — Glaze used to be capped at 128 members via structured binding limits.
* **Non-aggregate types** — Classes with custom constructors, virtual functions, and private members can all be reflected automatically.
* **Automatic inheritance** — Base class members are included automatically. No `glz::meta` specialization needed.
* **Automatic enum serialization** — Enums serialize as strings without any metadata.

Here's an example of non-aggregate types working out of the box:

class ConstructedClass {
public:
std::string name;
int value;

ConstructedClass() : name("default"), value(0) {}
ConstructedClass(std::string n, int v) : name(std::move(n)), value(v) {}
};

// Just works with P2996 — no glz::meta needed
std::string json;
glz::write_json(ConstructedClass{"test", 42}, json);
// {"name":"test","value":42}

Inheritance is also automatic:

class Base {
public:
std::string name;
int id;
};

class Derived : public Base {
public:
std::string extra;
};

std::string json;
glz::write_json(Derived{}, json);
// {"name":"","id":0,"extra":""}

constexpr auto names = glz::member_names<Derived>;
// {"name", "id", "extra"}

# New Data Formats

Since my last post about Glaze, we've added four new serialization formats. All of them share the same `glz::meta` compile-time reflection, so if your types already work with `glz::write_json`/`glz::read_json`, they work with every format. And these formats are directly supported in Glaze without wrapping other libraries.

# YAML (1.2 Core Schema)

struct server_config {
std::string host = "127.0.0.1";
int port = 8080;
std::vector<std::string> features = {"metrics", "logging"};
};

server_config config{};
std::string yaml;
glz::write_yaml(config, yaml);

Produces:

host: "127.0.0.1"
port: 8080
features:
- "metrics"
- "logging"

Supports anchors/aliases, block and flow styles, full escape sequences, and tag validation.

# CBOR (RFC 8949)

Concise Binary Object Representation. Glaze's implementation supports RFC 8746 typed arrays for bulk memory operations on numeric arrays, multi-dimensional arrays, Eigen matrix integration, and complex number serialization.

# MessagePack

Includes timestamp extension support with nanosecond precision and `std::chrono` integration.

# TOML (1.1)

struct product {
std::string name;
int sku;
};

struct catalog {
std::string store_name;
std::vector<product> products;
};

std::string toml;
glz::write_toml(catalog{"Hardware Store", {{"Hammer", 738594937}}}, toml);

Produces:

store_name = "Hardware Store"
[[products]]
name = "Hammer"
sku = 738594937

Native `std::chrono` datetime support, array of tables, inline table control, and enum handling.

# Lazy JSON (and Lazy

Читать полностью…

C++ - Reddit

Faster asin() Was Hiding In Plain Sight
https://16bpp.net/blog/post/faster-asin-was-hiding-in-plain-sight/

https://redd.it/1rqtw8q
@r_cpp

Читать полностью…

C++ - Reddit

vtz: the world's fastest timezone library
https://github.com/voladynamics/vtz

https://redd.it/1rqxnjb
@r_cpp

Читать полностью…

C++ - Reddit

C++26: The Oxford variadic comma
https://www.sandordargo.com/blog/2026/03/11/cpp26-oxford-variadic-comma

https://redd.it/1rqqdgv
@r_cpp

Читать полностью…

C++ - Reddit

Building a Package Manager on Top of Meson's Wrap System
https://collider.ee/blog/2026-03-09-2328_building_a_package_manager/

https://redd.it/1rpdrkf
@r_cpp

Читать полностью…

C++ - Reddit

FastParseX, A high‑performance C++ parser for huge CSV/Log/Binary files (mmap, zstd, Arrow/Parquet)

I've been working on a C++ parsing engine focused on processing very large files (GB-TB scale) with predictable performance and minimal allocations.

FastParseX supports:

\- zero-allocation CSV parsing (quoted fields, multiline, trimming)

\- log parsing (Apache/Nginx/custom formats)

\- binary parsing (endianness, slicing, struct reading)

\- memory-mapped I/O with madvise/prefetch

\- async buffered I/O

\- gzip/xz/zstd streaming

\- parallel chunk processing

\- profiling (type inference, cardinality, min/max)

\- Arrow export

\- Parquet export

Repo: https://github.com/FastParseX-dev/FastParseX

Feedback from people who care about low-level performance, parsing internals, or C++ API

design is very welcome.

https://redd.it/1rp4a5r
@r_cpp

Читать полностью…

C++ - Reddit

The compilation procedure for C++20 modules
https://holyblackcat.github.io/blog/2026/03/09/compiling-modules.html

https://redd.it/1royqvw
@r_cpp

Читать полностью…

C++ - Reddit

Implementing a Compile-Time Sudoku Solver in Modern C++ (C++20/23

I’ve been experimenting with **constexpr** and template metaprogramming in C++20/23, and I thought it would be fun to implement a **Sudoku solver entirely at compile-time**.

* The idea is to encode the Sudoku grid as `constexpr` arrays.
* All solving logic happens using **compile-time recursion and constraints**, leveraging concepts and `consteval` functions.
* The compiler does all the heavy lifting, so when the program runs, the solution is already baked in.

I’d love feedback on:

1. How to make the solver more **efficient for larger grids** at compile-time.
2. Best practices for **readable compile-time recursion** without hitting template depth limits.
3. How to **debug constexpr code** effectively in real-world projects.

I can share a **minimal working example** if people are interested.

Has anyone else tried doing heavy algorithmic work entirely at compile-time?

https://redd.it/1rougbu
@r_cpp

Читать полностью…

C++ - Reddit

Collider: A package and dependency manager for Meson (wrap-based)
http://collider.ee

https://redd.it/1rot7rc
@r_cpp

Читать полностью…

C++ - Reddit

Accessing inactive union members through char: the aliasing rule you didn’t know about
https://www.sandordargo.com/blog/2026/03/04/char-representation-and-UB

https://redd.it/1rn09z0
@r_cpp

Читать полностью…

C++ - Reddit

C++ Reflection: Another Monad
https://www.elbeno.com/blog/?p=1813

https://redd.it/1rn0512
@r_cpp

Читать полностью…

C++ - Reddit

illustrates the anti-pattern:

struct NetworkSystem
{
NetworkSystem(Gx::Context& ioc) // DON'T DO THIS. Stick with the example I provided above
{
config = ioc.Require<Config>();
logger = ioc.Require<Logger>();
timer = ioc.Require<Timer>();
profiler = ioc.Require<Profiler>();
}

Config* config; Logger* logger; Timer* timer; Profiler *profiler;
};

auto ioc = Gx::Context();
auto networkSystem = NetworkSystem(ioc); // just don't

The above case is an anti-pattern because **it hides dependencies.** When a class receives the entire container, its constructor signature no longer tells you what it actually needs, which defeats the purpose of [DI](https://en.wikipedia.org/wiki/Dependency_injection). IoC container should be primarily used in the root composition of your classes' initialization (e.g, your `main()`).

In addition, many IoC containers perform compile-time checks to some extent regardless of the language. By passing the container directly, you are giving up compile-time checks that the library can otherwise perform (e.g., `ioc.Require<NetworkSystem>()` may fail at compile-time if one of the dependencies is not constructible either by the library (multiple ambiguous constructors) or by the nature of the class itself). I think we all could agree that we should enforce compile-time checks whenever possible.

Just like other programming patterns, some exceptions may apply, and it might be more practical to go with anti-pattern in some particular situations (that's why `Require<T>` in my lib is exposed anyway, it could be used for different purposes).

There might be other anti-patterns I couldn't remember off the top of my head, but the above is the most common mistake. There are a bunch of resources online that discuss this.

This is a pretty common concept for web dev folk (and maybe gamedev?), but I guess it is not for your typical C++ dev

https://redd.it/1ro288e
@r_cpp

Читать полностью…

C++ - Reddit

peel - C++ bindings generator for GObject-based libraries
https://gitlab.gnome.org/bugaevc/peel

https://redd.it/1rod1sn
@r_cpp

Читать полностью…

C++ - Reddit

AMD GAIA v0.16.0 introduces a C++17 Agent Framework
https://github.com/amd/gaia/releases/tag/v0.16.0

https://redd.it/1rrsr5u
@r_cpp

Читать полностью…

C++ - Reddit

BEVE)

`glz::lazy_json` provides on-demand parsing with zero upfront work. Construction is O(1) — it just stores a pointer. Only the bytes you actually access get parsed.

std::string json = R"({"name":"John","age":30,"scores":[95,87,92]})";
auto result = glz::lazy_json(json);
if (result) {
auto& doc = *result;
auto name = doc["name"].get<std::string_view>(); // Only parses "name"
auto age = doc["age"].get<int64_t>(); // Only parses "age"
}

For random access into large arrays, you can build an index in O(n) and then get O(1) lookups:

auto users = doc["users"].index(); // O(n) one-time build
auto user500 = users[500]; // O(1) random access

You can also deserialize into structs directly from a lazy view:

User user{};
glz::read_json(user, doc["user"]);

# HTTP Server, REST, and WebSockets

Glaze now includes a full HTTP server with async ASIO backend, TLS support, and WebSocket connections.

# Basic server

glz::http_server server;

server.get("/hello", [](const glz::request& req, glz::response& res) {
res.body("Hello, World!");
});

server.bind("127.0.0.1", 8080).with_signals();
server.start();
server.wait_for_signal();

# Auto-generated REST endpoints using reflection

You can register C++ objects and Glaze will automatically generate REST endpoints from reflected methods:

struct UserService {
std::vector<User> getAllUsers() { return users; }
User getUserById(size_t id) { return users.at(id); }
User createUser(const User& user) { users.push_back(user); return users.back(); }
};

glz::registry<glz::opts{}, glz::REST> registry;
registry.on(userService);
server.mount("/api", registry.endpoints);

Method names are mapped to HTTP methods automatically — `get*()` becomes GET, `create*()` becomes POST, etc.

# WebSockets

auto ws_server = std::make_shared<glz::websocket_server>();

ws_server->on_message([](auto conn, std::string_view msg, glz::ws_opcode opcode) {
conn->send_text("Echo: " + std::string(msg));
});

server.websocket("/ws", ws_server);

https://redd.it/1rrq9e6
@r_cpp

Читать полностью…

C++ - Reddit

Qt Creator 19 released
https://www.qt.io/blog/qt-creator-19-released

https://redd.it/1rrpdxs
@r_cpp

Читать полностью…

C++ - Reddit

Julian Storer: Creator of JUCE C++ Framework (cross-platform C++ app & audio plugin development framework) | WolfTalk #032
https://youtu.be/svAdgZrkUV8?si=xcbfQuI5dCcMGisv

https://redd.it/1rrmd9y
@r_cpp

Читать полностью…

C++ - Reddit

std::promise and std::future

My googling is telling me that promise and future are heavy, used to doing an async task and communicating a single value, and are useful to get an exception back to the main thread.

I am asked AI and did more googling trying to figure out why I would use a less performant construct and what common use cases might be. It's just giving me ramblings about being easier to read while less performant. I don't really have an built in favoritism for performance vs readability and am experienced enough to look at my constraints for that.

However, I'd really like to have some good use-case examples to catalog promise-future in my head, so I can sound like a learned C++ engineer. What do you use them for rather than reaching for a thread+mutex+shared data, boost::asio, or coroutines?

https://redd.it/1rr7lj9
@r_cpp

Читать полностью…

C++ - Reddit

Corosio Beta - coroutine-native networking for C++20

We are releasing the Corosio beta - a coroutine-native networking library for C++20 built by the C++ Alliance. It is the successor to Boost.Asio, designed from the ground up for coroutines.

**What is it?**

Corosio provides TCP sockets, acceptors, TLS streams, timers, and DNS resolution. Every operation is an awaitable. You write co\_await and the library handles executor affinity, cancellation, and frame allocation. No callbacks. No futures. No sender/receiver.

It is built on Capy, a coroutine I/O foundation that ships with Corosio. Capy provides the task types, buffer sequences, stream concepts, and execution model. The two libraries have no dependencies outside the standard library.

**An echo server in 45 lines:**

#include <boost/capy.hpp>
#include <boost/corosio.hpp>

namespace corosio = boost::corosio;
namespace capy = boost::capy;

capy::task<> echo_session(corosio::tcp_socket sock)
{
char buf[1024];
for (;;)
{
auto [ec, n] = co_await sock.read_some(
capy::mutable_buffer(buf, sizeof(buf)));

auto [wec, wn] = co_await capy::write(
sock, capy::const_buffer(buf, n));

if (ec)
break;
if (wec)
break;
}
sock.close();
}

capy::task<> accept_loop(
corosio::tcp_acceptor& acc,
corosio::io_context& ioc)
{
for (;;)
{
corosio::tcp_socket peer(ioc);
auto [ec] = co_await acc.accept(peer);
if (ec)
continue;
capy::run_async(ioc.get_executor())(echo_session(std::move(peer)));
}
}

int main()
{
corosio::io_context ioc;
corosio::tcp_acceptor acc(ioc, corosio::endpoint(8080));
capy::run_async(ioc.get_executor())(accept_loop(acc, ioc));
ioc.run();
}

**Features:**

* Coroutine-only - every I/O operation is an awaitable, no callbacks
* TCP sockets, acceptors, TLS streams, timers, DNS resolution
* Cross-platform: Windows (IOCP), Linux (epoll), macOS/FreeBSD (kqueue)
* Type-erased streams - write any\_stream& and accept any stream type. Compile once, link anywhere. No template explosion.
* Zero steady-state heap allocations after warmup
* Automatic executor affinity - your coroutine always resumes on the right thread
* Automatic stop token propagation - cancel at the top, everything below stops Buffer sequences with byte-level manipulation (slice, front, consuming\_buffers, circular buffers)
* Concurrency primitives: strand, thread\_pool, async\_mutex, async\_event, when\_all, when\_any Forward-flow allocator control for coroutine frames
* C++20: GCC 12+, Clang 17+, MSVC 14.34+

**Get it:**

git clone https://github.com/cppalliance/corosio.git
cd corosio
cmake -S . -B build -G Ninja
cmake --build build

No dependencies. Capy is fetched automatically.

Or use CMake FetchContent in your project:

include(FetchContent)
FetchContent_Declare(corosio
GIT_REPOSITORY https://github.com/cppalliance/corosio.git
GIT_TAG develop
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(corosio)
target_link_libraries(my_app Boost::corosio)

**Links:**

* Corosio: [https://github.com/cppalliance/corosio](https://github.com/cppalliance/corosio)
* Corosio docs: [https://develop.corosio.cpp.al/](https://develop.corosio.cpp.al/)
* Capy: [https://github.com/cppalliance/capy](https://github.com/cppalliance/capy)
* Capy docs: [https://develop.capy.cpp.al/](https://develop.capy.cpp.al/)

**What’s next:**

HTTP, WebSocket, and high-level server libraries are in development on the same foundation. Corosio is heading for Boost formal review. We want your feedback.

https://redd.it/1rqykml
@r_cpp

Читать полностью…

C++ - Reddit

New C++ Conference Videos Released This Month - March 2026 (Updated To Include Videos Released 2026-03-02 - 2026-03-08)

**CppCon**

2026-03-02 - 2026-03-08

* Interesting Upcoming Low-Latency, Concurrency, and Parallelism Features from Wroclaw 2024, Hagenberg 2025, and Sofia 2025 - Paul E. McKenney, Maged Michael, Michael Wong - CppCon 2025 - [https://youtu.be/M1pqI1B9Zjs](https://youtu.be/M1pqI1B9Zjs)
* Threads vs Coroutines — Why C++ Has Two Concurrency Models - Conor Spilsbury - CppCon 2025 - [https://youtu.be/txffplpsSzg](https://youtu.be/txffplpsSzg)
* From Pure ISO C++20 To Compute Shaders - Koen Samyn - CppCon 2025 - [https://youtu.be/hdzhhqvYExE](https://youtu.be/hdzhhqvYExE)
* Wait is it POSIX? Investigating Different OS and Library Implementations for Networking - Katherine Rocha - CppCon 2025 - [https://youtu.be/wDyssd8V\_6w](https://youtu.be/wDyssd8V_6w)
* End-to-End Latency Metrics From Distributed Trace - Kusha Maharshi - CppCon 2025 - [https://youtu.be/0bPqGN5J7f0](https://youtu.be/0bPqGN5J7f0)

2026-02-23 - 2026-03-01

* Fix C++ Stack Corruptions with the Shadow Stack Library - Bartosz Moczulski - CppCon 2025 - [https://youtu.be/-Qg0GaONwPE](https://youtu.be/-Qg0GaONwPE)
* First Principles While Designing C++ Applications - Prabhu Missier - CppCon 2025 - [https://youtu.be/8mLo5gXwn4k](https://youtu.be/8mLo5gXwn4k)
* Matrix Multiplication Deep Dive || Cache Blocking, SIMD & Parallelization - Aliaksei Sala - CppCon 2025 - [https://youtu.be/GHctcSBd6Z4](https://youtu.be/GHctcSBd6Z4)
* Choose the Right C++ Parallelism Tool | Low-Level vs Async vs Coroutines vs Data Parallel - Eran Gilad - CppCon 2025 - [https://youtu.be/7a9AP4rD08M](https://youtu.be/7a9AP4rD08M)
* ISO C++ Standards Committee Panel Discussion 2025 - Hosted by Herb Sutter - CppCon 2025 - [https://youtu.be/R2ulYtpV\_rs](https://youtu.be/R2ulYtpV_rs)

**ADC**

2026-03-02 - 2026-03-08

* Efficient Task Scheduling in a Multithreaded Audio Engine - Algorithms and Analysis for Parallel Graph Execution - Rachel Susser - ADC 2025 - [https://youtu.be/bEtSeGr8UvY](https://youtu.be/bEtSeGr8UvY)
* The Immersive Score - Creative Advantages of Beds and Objects in Film and Game Music - Simon Ratcliffe - ADCx Gather 2025 - [https://youtu.be/aTmkr0yTF5g](https://youtu.be/aTmkr0yTF5g)
* Tabla to Drumset - Translating Rhythmic Language through Machine Learning - Shreya Gupta - ADC 2025 - [https://youtu.be/g14gESreUGY](https://youtu.be/g14gESreUGY)

2026-02-23 - 2026-03-01

* Channel Agnosticism in MetaSounds - Simplifying Audio Formats for Reusable Graph Topologies - Aaron McLeran - ADC 2025 - [https://youtu.be/CbjNjDAmKA0](https://youtu.be/CbjNjDAmKA0)
* Sound Over Boilerplate - Accessible Plug-Ins Development With Phausto and Cmajor - Domenico Cipriani - ADCx Gather 2025 - [https://youtu.be/DVMmKmj1ROI](https://youtu.be/DVMmKmj1ROI)
* Roland Future Design Lab x Neutone: diy:NEXT - Paul McCabe, Ichiro Yazawa & Alfie Bradic - ADC 2025 - [https://youtu.be/4JIiYqjq3cA](https://youtu.be/4JIiYqjq3cA)

**Meeting C++**

2026-03-02 - 2026-03-08

* Persistence squared: persisting persistent data structures - Juan Pedro Bolívar Puente - Meeting C++ - [https://www.youtube.com/watch?v=pQhHx0h-904](https://www.youtube.com/watch?v=pQhHx0h-904)

2026-02-23 - 2026-03-01

* Instruction Level Parallelism and Software Performance - Ivica Bogosavljevic - Meeting C++ 2025 - [https://www.youtube.com/watch?v=PMu7QNctEGk](https://www.youtube.com/watch?v=PMu7QNctEGk)
* Real-time Safety — Guaranteed by the Compiler! - Anders Schau Knatten Meeting C++ 2025 - [https://www.youtube.com/watch?v=4aALnxHt9bU](https://www.youtube.com/watch?v=4aALnxHt9bU)

https://redd.it/1rp5c8n
@r_cpp

Читать полностью…

C++ - Reddit

Reducing FFmpeg build times in practice

We compile FFmpeg from source regularly for custom codec work and video pipelines, so build time directly affects iteration speed. Baseline was a 24 minute clean build on a 16 core Xeon. During active development we were running multiple builds per day, and CI was consistently blocked on compilation.

ccache helped incremental builds but not clean CI runs. Disabling unused codecs with --disable-everything and enabling only what we needed saved about three minutes. NVMe storage produced marginal gains. Scaling cores and RAM helped up to 16 cores, then flattened out.

Profiling with ninja -d stats showed compilation at \~80 percent of wall time, linking at \~15 percent and mostly serial, configure at \~5 percent and serial.

We then tested distributed builds. distcc delivered roughly a 60 percent improvement but required nontrivial setup. icecc performed slightly better in our environment at around 65 percent. Incredibuild produced the largest gain at about 88 percent over baseline.

Final numbers:

Clean build: 24 minutes to 2 minutes 50 seconds

Incremental: 8 minutes to 45 seconds

Full CI pipeline: 35 minutes to 6 minutes

How far are you pushing distcc or icecc in workloads? Anyone managed to squeeze more out of them?

How are you handling LTO in distributed setups? Is there an approach that preserves most of the distributed gains without turning the final link into a long serial step?

For anyone working on other large C or C++ codebases, did distributed compilation create a similar step change, or did you hit a different ceiling first?

https://redd.it/1rp23xe
@r_cpp

Читать полностью…

C++ - Reddit

StockholmCpp 0x3C: Intro, event host presentation, C++ news and the quiz
https://youtu.be/_oluCPrUaQ4

https://redd.it/1rot31n
@r_cpp

Читать полностью…

C++ - Reddit

Lessons learned from 2 years of operating a C++ MMO game server in production 1/N

I've been working as a server team lead and technical director on a large-scale MMO for the past 2+ years, from launch through live service.

our server uses an in-house actor model.
The core parts of our code are over 15 years old.
It started with C++98. Now we use C++20.
We use modern C++, but old style code is still in many places.

One example is that we allow certain race conditions.
This codebase is older than the C++ memory model.
It worked then, and it still works now.

// attacker context
int32_t hp = target->hp(); // violates actor context, but allowed

Another example is our enum convention.
For enums that can have an empty state, we use INVALID as the first value.

enum class Weapon {
INVALID = 0,
Dagger,
Sword,
Bow,
};

We replaced INVALID with std::optional to separate the logic of "no value" from the actual data set.

// before
Weapon weapon = target->weapon();
if (weapon != Weapon::INVALID) {
Process(weapon);
}

// after
if (target->weapon().has_value()){
Process(target->weapon().value());
}

One month after we deployed it, we got a crash.
We identified the root cause through crash dump analysis. It was a TOCTOU problem.

// reading from another actor context
if (target->weapon().has_value()){
// another thread had changed the weapon.
Process(target->weapon().value()); // bad_optional_access
}

With INVALID, this would not have crashed.
We had to review all the code we changed.
We reverted the code that reads optional values from other actors back to the INVALID convention.

Now INVALID and std::optional coexist in our codebase.
We know that switching to std::atomic is the right fix.
But a simple swap could introduce other problems, so we are thinking it through carefully.

we did not review the existing code well enough before applying modern C++.
Legacy code has implicit rules.
Making code more explicit is what modern C++ is really for.

https://redd.it/1rotys6
@r_cpp

Читать полностью…

C++ - Reddit

Why std::pmr Might Be Worth It for Real‑Time Embedded C++
http://www.sapnag.me/blog/cppdev/2025-12-26-containers-std-vs-pmr/

https://redd.it/1rosl4c
@r_cpp

Читать полностью…

C++ - Reddit

Azrar - a String interning library for C++ with faster comparisons and reduced memory footprint"

Comments and critics are welcome :-)

Github link: [https://github.com/kboutora/Azrar](https://github.com/kboutora/Azrar)

This is a lightweight C++ (14 and +) library for string interning and indexing that can significantly improve performance in applications dealing with repeated string comparisons or using strings as maps key.

The library is header only.

**How it works:**

Instead of working with strings, Azrar maintains a dictionary where each unique string gets assigned a unique index..

Working with these unique indexes makes copying, comparing, and hashing operations substantially faster.

Github link: [https://github.com/kboutora/Azrar](https://github.com/kboutora/Azrar)

**Usage minimalist example:**

include "Azrar.h"
include <map>
include <iostream>

using IdxString = Azrar::StringIndex<uint32_t>;
int main(int , char **)
{

// Expect to print 4 (sizeof (uint32_t))
std::cout << "sizeof(IdxString): " << sizeof(IdxString) << " bytes\n\n";

IdxString city1("seattle");
IdxString city2("seattle");
IdxString city3("portland");

// Fast O(1) comparison (compares integers, not string contents)
if (city1 == city2) {
std::cout << "Same city!\n";
}

// Use as map keys - much faster lookups than std::string
std::map<IdxString, int> population;
population[city1] = 750000;
population[city3] = 650000;

// Access the original string when needed
std::cout << "City: " << city1.c_str() << "\n";
return 0;
}

https://redd.it/1rophrb
@r_cpp

Читать полностью…

C++ - Reddit

P4043R0: Are C++ Contracts Ready to Ship in C++26?

Are you watching the ISO C++ standardization pipeline? Looking for the latest status about C++ Contracts?

I'm curious to see the non-WG21 C++ community opinion.

The C++26 Contracts facility (P2900) is currently in the Working Draft, but the design is still the subject of substantial discussion inside the committee.

This paper raises the question of whether Contracts are ready to ship in C++26 or whether the feature should be deferred to a later standard.

Click -> P4043R0: Are C++ Contracts Ready to Ship in C++26?

I'm curious to hear the perspective of the broader C++ community outside WG21:
\- Do you expect to use Contracts?
\- Does the current design make sense to you?
\- Would you prefer a simpler model?

Feedback welcome.

https://redd.it/1rnh401
@r_cpp

Читать полностью…

C++ - Reddit

I made a single-header, non-intrusive IoC Container in C++17

[https://github.com/SirusDoma/Genode.IoC](https://github.com/SirusDoma/Genode.IoC)

A non-intrusive, single-header IoC container for C++17.

I was inspired after stumbling across a compiler loophole I found [here](https://alexpolt.github.io/type-loophole.html). Just now, I rewrote the whole thing without relying on that loophole because I just found out that my game sometimes won't compile on clang macOS without some workarounds.

Anyway, this is a similar concept to Java Spring, or C# Generic Host / Autofac, but unlike [kangaru](https://github.com/gracicot/kangaru) or other IoC libraries, this one is single header-only and most importantly: **non-intrusive**. Meaning you don't have to add anything extra to your classes, and it just works.

I have used this previously to develop a [serious game](https://www.reddit.com/r/gamedev/comments/1rldvqa/i_remade_an_online_retro_game_by_reverse/) with complex dependency trees (although it uses a previous version of this library, please check that link, it's made with C++ too), and a game work-in-progress that I'm currently working on with the new version I just pushed.

Template programming is arcane magic to me, so if you found something flawed / can be improved, please let me know and go easy on me 😅

**EDIT**

As requested, let me briefly talk about what IoC is:

IoC container stands for [Inversion of Control](https://en.wikipedia.org/wiki/Inversion_of_control), as mentioned, a similar concept to [Spring in Java](https://docs.spring.io/spring-framework/reference/core/beans/introduction.html). By extension, it is a [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) pattern that manages and abstracts dependencies in your code.

Imagine you have the following classes in your app:

struct NetworkSystem
{
NetworkSystem(Config& c, Logger& l, Timer& t, Profiler* p)
: config(&c), logger(&l), timer(&t), profiler(&p) {}

Config* config; Logger* logger; Timer* timer; Profiler *profiler;
};

In a plain old-school way, you initialize the `NetworkSystem` by doing this:

auto config = Config(fileName);
auto logger = StdOutLogger();
auto timer = Timer();
auto profiler = RealProfiler(someInternalEngine, someDependency, etc);

auto networkSystem = NetworkSystem(config, logger, timer, profiler);

And you have to manage the lifetime of these components individually. With IoC, you could do something like this:

auto ioc = Gx::Context(); // using my lib as example

// Using custom init
// All classes that require config in their constructor will be using this config instance as long as they are created via this "ioc" object.
ioc.Provide<Config>([] (auto& ctx) {
return std::make_unique<Config>(fileName);
});

// Usually you have to tell container which concrete class to use if the constructor parameter relies on abstract class
// For example, Logger is an abstract class and you want to use StdOut
ioc.Provide<Logger, StdOutLogger>();

// Now simply call this to create network system
networkSystem = ioc.Require<NetworkSystem>(); // will create NetworkSystem, all dependencies created automatically inside the container, and it will use StdOutLogger

That's the gist of it. Most of the IoC container implementations are customizable, meaning you can control the construction of your class object if needed and automate the rest.

Also, the lifetime of the objects is tied to the IoC container; this means if the container is destroyed, all objects are destroyed (typically with some exceptions; in my lib, using `Instantiate<T>` returns a `std::unique_ptr<T>`). On top of that, depending on the implementation, some libraries provide sophisticated ways to manage the lifetime.

I would suggest familiarizing yourself with the IoC pattern before trying it out to avoid anti-patterns: For example, passing the container itself to the constructor is considered an anti-pattern. The following code

Читать полностью…

C++ - Reddit

Exploring Mutable Consteval State in C++26
https://friedkeenan.github.io/posts/exploring-mutable-consteval-state/

https://redd.it/1ro1gfz
@r_cpp

Читать полностью…
Subscribe to a channel