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

Learn C++ by Example • Frances Buontempo & Matt Godbolt
https://youtu.be/PXKICIiXEUM?list=PLEx5khR4g7PJbSLmADahf0LOpTLifiCra

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

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

C++ - Reddit

Problems with a weak tryLock operation in C and C++ standards
https://forums.swift.org/t/se-0512-document-that-mutex-withlockifavailable-cannot-spuriously-fail/84789/3

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

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

C++ - Reddit

BitFields API: Type-Safe Bit Packing for Lock-Free Data Structures
https://rocksdb.org/blog/2025/12/31/bit-fields-api.html

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

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

C++ - Reddit

C++26: std::is_within_lifetime
https://www.sandordargo.com/blog/2026/02/18/cpp26-std_is_within_lifetime

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

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

C++ - Reddit

[https://www.youtube.com/watch?v=muJL-\_ymx-0](https://www.youtube.com/watch?v=muJL-_ymx-0)
* MARTIJN TERPSTRA - Low Overhead Multi-threaded Logging for Low-latency Applications - [https://www.youtube.com/watch?v=AjnQBHu0AhE](https://www.youtube.com/watch?v=AjnQBHu0AhE)
* FREDRICK OMONDI - Introduction to Writing and Profiling GPU Kernels - [https://www.youtube.com/watch?v=0PvjR\_\_R5kI](https://www.youtube.com/watch?v=0PvjR__R5kI)
* PHIL NASH - Mastering the Special Member Functions : The Rules of 0 to 5 and Beyond - [https://www.youtube.com/watch?v=PEr6XVALpVk&pp=0gcJCYcKAYcqIYzv](https://www.youtube.com/watch?v=PEr6XVALpVk&pp=0gcJCYcKAYcqIYzv)

**Meeting C++**

2026-01-26 - 2026-02-01

* Purging undefined behavior and Intel assumptions in Legacy Codebases - Roth Michaels - [https://www.youtube.com/watch?v=b7SZdhrEsic](https://www.youtube.com/watch?v=b7SZdhrEsic)
* 25+ years of pathfinding problems with C++ - Raymi Klingers - [https://www.youtube.com/watch?v=lEBQveBCtKY](https://www.youtube.com/watch?v=lEBQveBCtKY)
* Speed for Free - current state of auto vectorizing compilers - Stefan Fuhrmann - [https://www.youtube.com/watch?v=m2vVWkFsrM0](https://www.youtube.com/watch?v=m2vVWkFsrM0)

**ACCU Conference**

2026-01-26 - 2026-02-01

* The Beman Project: Testing C++ Library Proposals Before Standardization - Dietmar Kühl - ACCU 2025 Short Talks - [https://youtu.be/wXQE\_Upqbms](https://youtu.be/wXQE_Upqbms)
* A Sixth Seam in TDD? - Python Testing, Test Doubles & Legacy Code at Kosli - Jon Jagger - ACCU 2025 Short Talks - [https://youtu.be/62EltmSbqro](https://youtu.be/62EltmSbqro)
* What, What? - When We Think We Understand - Nara Morrison - ACCU 2025 Short Talks - [https://youtu.be/W0vAsaL\_svY](https://youtu.be/W0vAsaL_svY)

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

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

C++ - Reddit

Favorite optimizations ??

I'd love to hear stories about people's best feats of optimization, or something small you are able to use often!

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

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

C++ - Reddit

CppCon 2026 - Cost & Preparations

Hi Everyone, 

I'm planning to attend CppCon 2026 for the first time.
I'll be flying from the other half of the world for this, which isn't cheap by any means (tickets are around$1700).
I've been saving up money for some time now, but I was wondering, can somebody help me with how much the tickets and accommodations cost in general so I can be prepared ?
I understand that tickets sell cheaper usually for students. If so, how much cheaper? (I'm a student if that makes a difference.)

Thanks in advance guys!

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

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

C++ - Reddit

Title: UltrafastSecp256k1 — Zero-dependency C++20 secp256k1 with ASM backends, CUDA/ROCm, and 9 platform targets

After 3+ years of development, I'm sharing **UltrafastSecp256k1** — a complete secp256k1 implementation in modern C++20 with zero external dependencies.

**What makes it different:**

* **Zero dependencies** — SHA-256, SHA-512, Keccak-256, RIPEMD-160, Base58, Bech32 all implemented from scratch
* **Multi-backend assembly** — x64 MASM/GAS (BMI2/ADX), ARM64 (MUL/UMULH), RISC-V (RV64GC)
* **SIMD** — AVX2/AVX-512 batch operations, Montgomery batch inverse
* **GPU** — CUDA (4.63M kG/s), OpenCL (3.39M kG/s), ROCm/HIP
* **Constant-time** — Separate `secp256k1::ct` namespace, Montgomery ladder, no flag switching
* **Hot path contract** — Zero heap allocations, explicit buffers, fixed-size POD, in-place mutation
* **9 platforms** — x64, ARM64, RISC-V, ESP32, STM32, WASM, iOS, Android, CUDA/ROCm

**Protocol coverage:**
ECDSA (RFC 6979, low-S, recovery), Schnorr (BIP-340), MuSig2, FROST, Adaptor sigs, Pedersen commitments, Taproot, BIP-32/44, Silent Payments (BIP-352), ECDH, multi-scalar multiplication, batch verification, 27+ coin address generation.

**Design philosophy:**


**Algorithm > Architecture > Optimization > Hardware**

**Memory traffic > Arithmetic**

**Correctness is absolute; performance is earned**

Everything is `constexpr`\-friendly where possible. No exceptions, no RTTI, no virtual calls in compute paths.

200+ tests, fuzz harnesses, known vector verification.

Happy to answer questions about the architecture, assembly backends, or GPU implementation.

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

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

C++ - Reddit

Simulating Atoms Using C++
https://www.youtube.com/watch?v=OSAOh4L41Wg

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

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

C++ - Reddit

HPX Tutorials: Futures & Async
https://www.youtube.com/watch?v=OZWTmrlWUF0

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

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

C++ - Reddit

Another writeup of how to implement C++ coroutines

https://rhidian-server.com/implementing-c-coroutines/

Hope you enjoy, feel free to provide critiques and/or feedback :) I want to tackle coroutine memory safety next, as it's something that's really essential to coroutines and using them throughout your codebase

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

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

C++ - Reddit

Your Optimized Code Can Be Debugged - Here's How With MSVC C++ Dynamic Debugging - Eric Brumer
https://youtu.be/YnbO140OXuI?si=4TH-5q78yyB0z-ME

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

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

C++ - Reddit

Profiling on Windows: a Short Rant · Mathieu Ropert
https://mropert.github.io/2026/02/13/profiling_on_windows/

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

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

C++ - Reddit

MigrationManager::GetInstance();
manager.CreateMigrationHistory();
size_t applied = manager.ApplyPendingMigrations();
```

Supports rollbacks, dry-run preview, checksum verification, and distributed locking for safe concurrent deployments.

---

## Backup & Restore

Full database backup/restore with progress reporting:

```cpp
#include <Lightweight/SqlBackup.hpp>

// Backup to compressed archive (multi-threaded)
SqlBackup::Backup(
"backup.zip",
connectionString,
4, // concurrent workers
progressManager,
"", // schema
"*", // table filter (glob)
{}, // retry settings
{ .method = CompressionMethod::Zstd, .level = 6 }
);

// Restore
SqlBackup::Restore("backup.zip", connectionString, 4, progressManager);
```

Preserves indexes, foreign keys (including composite), and supports table filtering.

---

## Supported Databases

- Microsoft SQL Server
- PostgreSQL
- SQLite3

Works anywhere ODBC works (Windows, Linux, macOS).

---

## What's Next

We're actively developing and would love feedback. The library is production-ready for our use cases, but we're always looking to improve the API and add features.

We also consider abstracting away ODBC such that it could support non-ODBC databases like SQLite3 directly without the ODBC layer. That's a longer-term goal, but definitely a goal.

We currently focus on SQL tooling (migrations and backup/restore) as both are quite young additions that are still evolving.

Questions and PRs welcome!

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

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

C++ - Reddit

What coding style would make you adopt a C++ library?

I maintain https://github.com/aregtech/areg-sdk, a C++ framework for building distributed service-oriented systems. Think of it as a lightweight alternative to gRPC/DDS for cases where your services need to work identically across threads, processes, and networked machines. Same code, zero changes, just reconfigure the deployment.

We're planning a major modernization pass (targeting min C++17) and kicked off a https://github.com/aregtech/areg-sdk/discussions/669 in the repo. Before we commit to breaking changes, I'd love to hear what the community actually prefers.

Quick context on what we have at the moment:

PascalCase types, camelCase methods, mPascalCase members
Mixture of const char* and std::string_view in public APIs
Mixture of plain and smart pointers
Macros for logging scopes, code visibility, and code generator
C++17 minimum required version

What we're considering:

Modernizing APIs to use std::string_view, constexpr, and concepts (if we go for C++20)
Smart pointers where applicable
Switching to snake_case to align with STL (or maybe staying camelCase?)
Reducing macro usage where C++17/C++20 features can replace them
Two-parameter logging macros to fix path separator ambiguity (if switch camel_case)

The real question: When you evaluate a C++ library, what makes you close the tab? Is it the naming convention / coding style? The API modernity? Documentation? Something else entirely?

Some modernizations are crystal clear. Others are not. For example, is it worth switching to C++20, or will that lock out embedded developers (embedded Linux, Zephyr RTOS)? Which version of C++ are you using in your projects, and would you be willing to adopt a library that requires C++20?

If you're curious about the architecture: it's an event-driven, fire-and-forget model where services communicate through auto-generated proxies. The framework handles serialization, message routing, and thread-safe dispatch. A service consumer calls requestXxx(param), the provider implements requestXxx(param) and calls responseXxx(result). All routing is automatic. The same code works for inter-thread, IPC, and network communication, where the transport remains transparent.

Would love honest feedback. We're a small project trying to do things right.

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

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

C++ - Reddit

MSVC Build Tools 14.51 Preview released
https://devblogs.microsoft.com/cppblog/microsoft-c-msvc-build-tools-v14-51-preview-released-how-to-opt-in/

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

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

C++ - Reddit

Parallel C++ for Scientific Applications: Tasks & Concurrency (2nd Part)
https://www.youtube.com/watch?v=l-QUaAH_JJs

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

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

C++ - Reddit

I made a minimal SDL3 starter template with CMake and vcpkg — cross-platform, no bundled libs

Been doing C++ game dev for a while and got tired of setting up the same boilerplate every time I started a new SDL project. Put together a clean starter template with SDL3, SDL3_image, and SDL3_ttf managed via vcpkg so dependencies just work on Linux, macOS, and Windows.

Includes a basic SDLWindow class, hardware-accelerated renderer, and a game loop ready to go. Nothing fancy, just a solid starting point.

https://github.com/Tanner-Davison/sdl3-starter-template

Happy to answer questions about the setup or take feedback on the structure.

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

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

C++ - Reddit

Sourcetrail (Fork) 2025.12.8 released

Hi everybody,

Sourcetrail 2025.12.8, a fork of the C++/Java source explorer, has been released with these changes:

C++: Add indexing of structured binding declarations
C++: Add indexing of auto prvalue casts
GUI: Fix error/status view not cleared between indexing
C/C++: Replace msvc mulitithreading library switches with corresponding clang switches
C/C++: Add Visual Studio 2026 support
Database: Enable simple database performance improvement

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

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

C++ - Reddit

New C++ Conference Videos Released This Month - February 2026 (Updated To Include Videos Released 2026-02-09 - 2026-02-15)

**CppCon**

2026-02-09 - 2026-02-15

* A Case-study in Rewriting a Legacy Gui Library for Real-time Audio Software in Modern C++ (Reprise) - Roth Michaels - CppCon 2025 - [https://youtu.be/ag\_WNEDwFLQ](https://youtu.be/ag_WNEDwFLQ)
* Back to Basics: Master the static inline, const, and constexpr C++ Keywords - Andreas Fertig - CppCon 2025 - [https://youtu.be/hLakx0KYiR0](https://youtu.be/hLakx0KYiR0)
* std::execution in Asio Codebases: Adopting Senders Without a Rewrite - Robert Leahy - CppCon 2025 - [https://youtu.be/S1FEuyD33yA](https://youtu.be/S1FEuyD33yA)
* Back to Basics: Custom Allocators Explained - From Basics to Advanced - Kevin Carpenter - CppCon 2025 - [https://youtu.be/RpD-0oqGEzE](https://youtu.be/RpD-0oqGEzE)
* Your Optimized Code Can Be Debugged - Here's How With MSVC C++ Dynamic Debugging - Eric Brumer - CppCon 2025 - [https://youtu.be/YnbO140OXuI](https://youtu.be/YnbO140OXuI)

2026-02-02 - 2026-02-08

* Connecting C++ Tools to AI Agents Using the Model Context Protocol (MCP) - Ben McMorran - [https://youtu.be/NWnbgwFU1Xg](https://youtu.be/NWnbgwFU1Xg)
* The Truth About Being a Programmer CEO - Greg Law - [https://youtu.be/e8kNoLCW\_Rs](https://youtu.be/e8kNoLCW_Rs)
* An Introduction to the new C++ 26 "Reflection" Feature - Inbal Levi - [https://youtu.be/HBkG5DpLYo0](https://youtu.be/HBkG5DpLYo0)
* CMake Doesn't Have to Be Painful | Simple Strategies That Work - Bret Brown - [https://youtu.be/NDfTwOvWIao](https://youtu.be/NDfTwOvWIao)
* Parallel Range Algorithms: The Evolution of Parallelism in C++ - Ruslan Arutyunyan - [https://youtu.be/LVDr0132vUI](https://youtu.be/LVDr0132vUI)

2026-01-26 - 2026-02-01

* Using Floating-point in C++: What Works, What Breaks, and Why - Egor Suvorov - [https://youtu.be/m83TjrB6wYw](https://youtu.be/m83TjrB6wYw)
* Cross-Platform Package Management for Modern C++ Development with Pixi - Ruben Arts - [https://youtu.be/SQk0lKv2swk](https://youtu.be/SQk0lKv2swk)
* Mastering the Code Review Process - Pete Muldoon - [https://youtu.be/6a3CNRMssQE](https://youtu.be/6a3CNRMssQE)
* Networks in C++ - What's Actually Changing? - Ignas Bagdonas - [https://youtu.be/dVSCMJlHXQM](https://youtu.be/dVSCMJlHXQM)
* Compiler Explorer: The Features You Never Knew Existed - Matt Godbolt - [https://youtu.be/3W0vE\_VKokY](https://youtu.be/3W0vE_VKokY)

**ADC**

2026-02-09 - 2026-02-15

* How To Learn Audio Plugin Development With JUCE in 2026 (for free) - Jan Wilczek & Tom Poole - ADC 2025 - [https://youtu.be/MCL1BRsEEYc](https://youtu.be/MCL1BRsEEYc)
* Learnings from a Decade of Being a Mentor in Game Audio - Jorge Garcia - ADCx Gather 2025 - [https://youtu.be/Er\_C2652Bxw](https://youtu.be/Er_C2652Bxw)
* Channel Agnosticism in MetaSounds - Simplifying Audio Formats for Reusable Graph Topologies - Aaron McLeran - ADC 2025 - [https://youtu.be/vC-jnag-w9Q](https://youtu.be/vC-jnag-w9Q)

2026-02-02 - 2026-02-08

* Real-Time, Low Latency and High Temporal Resolution Spectrograms - Alexandre R.J. Francois - [https://youtu.be/QbNPA5QJ6OU](https://youtu.be/QbNPA5QJ6OU)
* Audio Codec Switching in the Linux Kernel for Automotive Edge Devices - Rutvij Trivedi - [https://youtu.be/eo2wWQQNYbI](https://youtu.be/eo2wWQQNYbI)
* Instrument Your Code So it Can Sing - Adam Shield - [https://youtu.be/Ll8h2ASyicA](https://youtu.be/Ll8h2ASyicA)

2026-01-26 - 2026-02-01

* Minimalistic Music Composition with C++ - Xyzzy - ADCx Gather 2025 - [https://youtu.be/9x49IxlrkqI](https://youtu.be/9x49IxlrkqI)
* The Real Waveform Matters - The Samples Are Not Always What They Seem - Jamie Angus-Whiteoak - ADC 2025 - [https://youtu.be/8eEWK6Fez8c](https://youtu.be/8eEWK6Fez8c)

**C++ Under The Sea**

2026-02-02 - 2026-02-09

* INBAL LEVI - Welcome to 0.1 of the meta::\[\[verse\]\]! - [https://www.youtube.com/watch?v=PEr6XVALpVk&amp;pp=0gcJCYcKAYcqIYzv](https://www.youtube.com/watch?v=PEr6XVALpVk&amp;pp=0gcJCYcKAYcqIYzv)
* LIEVEN DE COCK - Space Invaders: The Spaceship Operator is upon us -

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

C++ - Reddit

Back to Basics: Iterators in C++ - Nicolai Josuttis - CppCon 2023
https://www.youtube.com/watch?v=26aW6aBVpk0

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

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

C++ - Reddit

The story of making RocksDB ingestion 23x times faster
https://blog.serenedb.com/building-faster-ingestion

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

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

C++ - Reddit

Writing my own version control in cpp (Cpp my toxic lover)

damn i love cpp

but idk if cpp loves me back . raw dawgging a version control its called D.I.C.K

here's a link look at it roast it make me cry

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

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

C++ - Reddit

Unordered vector
https://github.com/Mjz86/String/blob/main/unordered_vector.md

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

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

C++ - Reddit

Back to Basics: (Range) Algorithms in C++ - Klaus Iglberger - CppCon 2023
https://www.youtube.com/watch?v=eJCA2fynzME

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

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

C++ - Reddit

Automatic casting with applications to extension methods and UFCS (language evolution)

INTRODUCTION

I'm a fan of UFCS, I probably think too much about it. Maybe here's a different direction towards UFCS.
The idea is that a simple language addition could (through some development)
lead to Extension Methods and UFCS.

This language addition might be called automatic casting.

CHAPTER 1: AUTO-CAST

Say that I want to call the std::string member function find_first_of on a const char*
string, "Hello3".

Of course, I can't call

"Hello3".findfirstof("123")

but it's easy if I first convert the C string into a std::string:

string("Hello3").findfirstof("123")

Maybe we could invent some syntax to tell the compiler to
auto-cast a const char* to a string, where needed:

// auto-cast const char to string.
auto operator string(const char
s){return string(s);}

We have entered the realm of MMINAE (missing member is not an error). If the
compiler can't resolve a member function, it will then apply the user-defined
auto-casts (in order) until the casted value can resolve the member function, which
is then used.

More complicated auto-casts can be defined. For example, this will
auto-cast an int to a string, by converting the digits to ASCII:

auto operator string(int n){return tostring(n);}

Then this allows code like:

(654321).find
firstof("123")

which will, after some MMINAE scanning, convert this code to:

to
string(654321).findfirstof("123")

CHAPTER 2: EXTENSION METHODS

I'd like to extend std::string by adding another member function, hasInt(int n).
Not by actually going into the <string> header file and adding a member function,
but by creating some code to give that illusion.

First, I define a helper class that provides the hasInt member function:

struct StringHasInt : public string {
bool hasInt(int n){
return this->contains(tostring(n));
}
};

Then define an auto-cast from a `string` to a `StringHasInt`:

auto operator StringHasInt(string s){return static
cast<StringHasInt>(s);}

Thus, when I call hasInt on a string:

string text;
...
text.hasInt(123);

MMINAE scanning will activate, and resolve the missing member by converting to the code:

staticcast<StringHasInt>(text).hasInt(123);

**CHAPTER 3: UFCS**

So, if we want to "do the UFCS" and would like to get from:

bool hasInt(const string s, int n){...etc...

to

text.hasInt(123)

by a simple macro call:

MAKE
UFCS(hasInt);

How is this done? The macro magic to convert this to a
helper class followed by an auto-cast is
left as an exercise to the reader!

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

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

C++ - Reddit

Library for Interactive/REPL CLI?

Im developing a time series database that requires an interactive CLI, I was recommended CLI11 however this isn't good for interactive/REPL style CLIs, any suggestions?

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

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

C++ - Reddit

Learn Task-Parallel Programming using Taskflow and Modern C++ -- Video Series
https://www.youtube.com/playlist?list=PLyCypiNN-fjlSioqrEkL4QsKZBawA5Zk1

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

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

C++ - Reddit

Lightweight: Almost-zero-overhead C++23 SQL library with DataMapper ORM, migrations, and backup/restore

Hi r/cpp,

We're excited to share **Lightweight**, a modern C++23 ODBC wrapper we've been building to solve our need for high-level SQL access without runtime overhead.

**Philosophy:** Down-to-zero runtime cost is mandatory requirement. We reduce high-level API into near-raw ODBC calls during compilation by using compile-time reflection techniques.

**GitHub:** https://github.com/LASTRADA-Software/Lightweight/
**Docs:** https://lastrada-software.github.io/Lightweight/

---

## Low-Level API: SqlStatement & SqlConnection

For those who want direct control, the core API is clean and minimal:

```cpp
auto stmt = SqlStatement {};

// Direct execution
stmt.ExecuteDirect("SELECT * FROM Users WHERE age > 21");
while (stmt.FetchRow())
std::println("{}: {}", stmt.GetColumn<int>(1), stmt.GetColumn<std::string>(2));

// Prepared statements with type-safe binding
stmt.Prepare(R"(INSERT INTO Employees (name, department, salary) VALUES (?, ?, ?))");
stmt.Execute("Alice", "Engineering", 85'000);
stmt.Execute("Bob", "Sales", 72'000);

// Output column binding
std::string name(50, '\0');
int salary {};
stmt.Prepare("SELECT name, salary FROM Employees WHERE id = ?");
stmt.BindOutputColumns(&name, &salary);
stmt.Execute(42);
```

### Bulk Insertions

Insert thousands of rows efficiently with a single call:

```cpp
stmt.Prepare(R"(INSERT INTO Employees (name, department, salary) VALUES (?, ?, ?))");

// Works with mixed container types
auto names = std::array { "Alice"sv, "Bob"sv, "Charlie"sv };
auto depts = std::list { "Eng"sv, "Sales"sv, "Ops"sv }; // even non-contiguous!
unsigned salaries[] = { 85'000, 72'000, 68'000 };

stmt.ExecuteBatch(names, depts, salaries); // Single ODBC batch call
```

Three batch methods for different scenarios:
- `ExecuteBatchNative()` - Fastest, requires contiguous memory
- `ExecuteBatchSoft()` - Works with any range (std::list, etc.)
- `ExecuteBatch()` - Auto-selects the best method

---

## DataMapper: High-Level ORM

Define your schema as C++ structs, and the DataMapper handles the rest:

```cpp
struct Person
{
Field<SqlGuid, PrimaryKey::AutoAssign> id;
Field<SqlAnsiString<25>> name;
Field<bool> is_active { true };
Field<std::optional<int>> age;
};

void Example(DataMapper& dm)
{
dm.CreateTable<Person>();

auto person = Person { .name = "John", .is_active = true, .age = 30 };
dm.Create(person); // INSERT - id auto-assigned

person.age = 31;
dm.Update(person); // UPDATE

// Fluent query API
auto active = dm.Query<Person>()
.Where(FieldNameOf<&Person::is_active>, "=", true)
.OrderBy(FieldNameOf<&Person::name>)
.All();

dm.Delete(person); // DELETE
}
```

---

## Relationships with Lazy Loading

```cpp
struct User
{
Field<SqlGuid, PrimaryKey::AutoAssign> id;
Field<SqlAnsiString<30>> name;
HasMany<Email> emails; // One-to-many
};

struct Email
{
Field<SqlGuid, PrimaryKey::AutoAssign> id;
Field<SqlAnsiString<100>> address;
BelongsTo<&User::id, SqlRealName{"user_id"}> user; // <--- Foreign key relation
};

// Navigate relationships naturally
auto email = dm.QuerySingle<Email>(emailId).value();
auto userName = email.user->name; // Lazy-loaded

// Or iterate
user.emails.Each([](Email const& e) {
std::println("Email: {}", e.address.Value());
});
```

Also supports `HasManyThrough` for many-to-many relationships via join tables.

---

## Database Migrations in Pure C++

No external tools or SQL files - define migrations as C++ code:

```cpp
LIGHTWEIGHT_SQL_MIGRATION(20240115120000, "create users table")
{
using namespace SqlColumnTypeDefinitions;

plan.CreateTable("users")
.PrimaryKey("id", Guid())
.RequiredColumn("name", Varchar(50)).Unique().Index()
.RequiredColumn("email", Varchar(100)).Unique()
.Column("password", Varchar(100))
.Timestamps(); // created_at, updated_at
}

// Apply pending migrations
auto& manager =

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

C++ - Reddit

to each client's send buffer via ZeroCopyOutputStream → N serializations
* Optimized: serialize once to a lightweight buffer, then memcpy to each client's send buffer

&#8203;

// Before: O(N) serializations
for (auto& client : clients) {
client->Send(message); // serializes each time
}

// After: O(1) serialization + O(N) memcpy
LightWeightSendStream stream;
message.SerializeToZeroCopyStream(&stream);
for (auto& client : clients) {
client->Send(stream); // fast memcpy only
}

# 7. Debugging memory corruption with hardware breakpoints

We had a bug where a 192-byte lambda capture was being corrupted at byte offset 136 — intermittently, in production only. Traditional debugging was useless.

Our approach:

1. **Canary message:** Send a dummy message of the same size before the real one. The dummy gets corrupted instead, and we detect it with a known byte pattern.
2. **Hardware breakpoints:** Use CPU debug registers (DR0–DR7) to trigger on write access to the predicted corruption address at runtime.

&#8203;

CONTEXT context;
context.Dr0 = (DWORD_PTR)(target_address); // address to watch
context.Dr7 |= (1 << 0); // enable Dr0
context.Dr7 |= (1 << 16); // write access
context.Dr7 |= (3 << 18); // 4 bytes
SetThreadContext(thread_handle, &context);

Combined with `AddVectoredExceptionHandler` and `CaptureStackBackTrace`, this lets us catch the exact call stack that writes to a specific memory address — without attaching a debugger.

**Limitation:** Hardware breakpoints are per-thread (set via thread context), so you only catch corruption if the writing thread is the one with the breakpoint installed.

# 8. Async stack traces for crash dump analysis

With deeply nested async calls (Post → Promise → Task), traditional call stacks are useless — you just see the event loop scheduler. We implemented [async stack traces inspired by Folly](https://developers.facebook.com/blog/post/2021/09/16/async-stack-traces-folly-Introduction/) and Visual Studio Natvis visualizations to reconstruct the logical async call chain in crash dumps.

For unhandled exceptions in coroutines, we store the source location in a static variable so crash dumps always show where the coroutine was last suspended — bridging the gap between the physical stack (scheduler) and the logical stack (your actual code).

# 9. Modern C++ features we adopted (and pre-implemented)

We use C++20 fully (Concepts, Ranges, Coroutines — but not Modules yet, VS support was insufficient at launch). We also pre-implemented several C++23/26 features:

* `std::expected` (C++23) — error handling without exceptions
* `std::ranges::to`, `enumerate`, `zip`, `cartesian_product` (C++23)
* `std::function_ref` (C++26) — lightweight non-owning callable wrapper, zero allocation
* `std::ranges::concat_view` (C++26)

We tried to adopt C++20 Modules in early 2023 but had to stop due to incomplete VS implementation. We're preparing to retry now with VS 2022 updates.

We're excited about C++26's Compile-time Reflection, `hazard_pointer`/RCU, Execution control library, and Contracts.

Happy to answer questions about any of these topics. After 2 years of live service with millions of players, the biggest takeaway is: **the bugs that matter in production are almost never the ones you test for.**

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

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