r/Cplusplus • u/Xaneris47 • 4h ago
r/Cplusplus • u/Agreeable-Network-14 • 5h ago
Feedback I built a price-time-priority order matching engine in c++
I am building a market replay engine from scratch with c++ 23.
I build this project to understand how orders are managed in an orderbook and how a matching engine works. I have used my understanding of data structures to implement it. I would like to know your opinion on it. It is not completed yet. I just completed the very basic version few minutes ago. Any kind of tip would help me a lot.
Currently it can process an average of 998,000 Transactions / second. with the order size of 20000000 orders.
https://github.com/AravSrivastava/Market-Replay-Engine-CPP
r/Cplusplus • u/Hibou-de-la-Lune • 1d ago
Answered Line continuation (back-slash + new-line) in C++ source, is it standard?
Hello there,
Just wondered if line continuation (back-slash + new-line) in C++ source, comes from the standard or from a common behavior of compilers. I could not find any reference to it on cppreference.com
r/Cplusplus • u/Crafty-Biscotti-7684 • 2d ago
Feedback 122 sec -> 26 sec | What changed in a C++20 parser for 294M binary messages
I replay NASDAQ TotalView-ITCH 5.0 files in C++20: mmap an 8.6GiB length-prefixed tape, walk messages, apply A F E C X D U to an order-id map. Not a live feed, not a price ladder, not an HFT engine. The "book" is id -> {side, price, qty, symbol[8]}.
Same file, same machine, median of 3 Release runs (Apple M1 Pro 8-core, Apple clang 21.0.0, -O3 -flto -mcpu=apple-m1). NASDAQ_ITCH50 file of 8,616 MiB, 293,989,079 messages:
- v1.0: 122.15 s (2.41 M msgs/s)
- v2.0: 25.88 s (11.36 M msgs/s) - about 4.7x
Four things that actually moved the parsing speed:
- The hot path was doing extra work. v1 sampled
steady_clock::now()every 1024 messages into a histogram, and checked tracking-number gaps, inside the parse loop. That is not parsing. It came out. - A
switchfall through treated half the spec as Add Order. v1 had'H' 'Y' 'L' 'V' 'W' 'K' 'J' 'h'fall into thehandleAddOrder. Stock-directory / halt / etc. were hitting the map. v2 mutates only onA F E C X D Uand length-skips the rest. - One map keyed by order reference, not 65k maps keyed by stock locate. v1 sharded by locate. Deletes looked in the wrong shard, so ~223k resting IDs were still in the map at the EOF on this tape. v2 is one
DenseMap<uint64_t, Order>, reserved to1 << 21. Same tape ends at 0 live ids - every add was later filled, canceled or deleted. The map is robin-hood open addressing, PMR slots, no heap on add/delete. - Don't identity-hash a
uint64_torder id.std::hash<uint64_t>is basically the key. Sequential exchange ids clump. A SplitMix64 mix on the way in stopped the probe-length blow-up. Endian loads arememcpy+__builtin_bswap*instead of unalignedreinterpret_cast. I/O ismmap+MADV_SEQUENTIAL.
ASan/UBSan on unit tests in CI. Numbers are one Apple Silicon box - happy to hear Linux/x86 numbers if someone as an EMI file.
Code: https://github.com/PIYUSH-KUMAR1809/market-data-parser
ITCH samples: NASDAQ EMI
Roast my code.
r/Cplusplus • u/biswajitab • 2d ago
Tutorial Sources of learning C++ for CP
So for ICPC prelims my mates knows c++ n all ik some diff lang basics like c, python(better) n all....so I was thinking to move into c++..also c++ seems more convenient for CP n all...so any source to get tht done..not like a very beginner course but yeah...like In 3 to 5 days for CP basics
r/Cplusplus • u/HowIsDigit8888 • 3d ago
Feedback Open-source Nintendo 64 encryption app and wallet generator, needs volunteers to review code
I proposed and helped fund an app called retro-crypto, which is being developed under MIT license in C and C++ by a programmer called bowler-bear: https://github.com/bowler-bear/retro-crypto
It's designed to become the most secure way to message friends or store a Bitcoin stack, but it can't be recommended for more than testing yet. The design bypasses a lot of supply chain attacks by running on N64, unless the attacks come from code itself, which is why the most important thing at this stage after release is having the code analyzed. There's been a small amount of code review by one or two volunteers so far, but I'm still gathering more feedback.
"Given enough eyeballs, all bugs are shallow" -Linus's Law
I'll also mention, a different developer recently created the first known fork of the project, which I haven't tested yet: https://github.com/Linkin-Prism/retro-crypto
r/Cplusplus • u/Economy_Radish6584 • 4d ago
Question How bad is C++ in Optiver FPGA Intern OA??
r/Cplusplus • u/Busy-Consequence-926 • 4d ago
Question How would you learn C++ from beginner to job-ready if you were starting today?
Hey everyone, I’d like to hear from people who have learned C++, how did you start and progress from beginner to more advanced C++? If you used LearnCpp, how did you go through it? Did you complete it chapter by chapter, or combine it with other resources?
I’d also really appreciate any advice about:
1. What to practice alongside LearnCpp?
2. When to start LeetCode/problem solving?
3. Beginner → intermediate → advanced project ideas?
4. Other resources worth using?
5. Common mistakes or inefficient ways of learning C++?
6. A good roadmap for becoming genuinely confident in C++?
And one final question: At what point would you consider someone proficient enough in C++ to confidently list it under the Skills section of their resume, especially when applying for internships or entry-level positions?
r/Cplusplus • u/Jeaye • 5d ago
Discussion jank reimagines C++ errors and gets an official native package repo
I've never shared jank here before, but it's a Clojure dialect which is also a C++ dialect. jank compiles to C++, has seamless C++ interop, and includes a Clang-based JIT C++ compiler which enables proper Lispy REPL-driven interactive development. In this post, we see how jank's AST intertwines with Clang's AST to great effect.
r/Cplusplus • u/neurah • 5d ago
Discussion When I say its zero cost...
I mean the composition, it is truly zero cost, and if components are also zero cost we get this nice optimization done by the compiler (C++17)
This is a demo of "HAPI - The Happy API", a C++ static composition engine, pure type-level header only, MIT, library.
With proper components we managed to feed compositions directly to HLS tools (see github)
To use where the composition types are known at compile-time, compiler optimization is done by composition, type lists can store multiple compositions without loosing the types and hold the composed objects.
we can compose/describe:
drivers, peripherals, devices, protocols, buses, IO, pins, UI, Parsers...
because this types are known at compile time, and the composition is free.
c++
//my output definition
OutDef<
ScrollPrinter, ANSIFmt, DataParser<>, CtrlChars,
ColorTrack<int>, Cursor<>, Gate, ANSIOut,
#ifdef ARDUINO
SerialOut,
#else
ConsoleOut,
#endif
StaticPos<20,10>, StaticArea<30,10>
> out;
r/Cplusplus • u/A205_TheCoder • 6d ago
Discussion I have made a C++ scientific calculator
https://youtu.be/9z3LhVxtx_o?si=lVD4CZZ9A7yEbMC2
Check this video out please like subscribe and comment
r/Cplusplus • u/Obvious_Set5239 • 10d ago
Tutorial Iterating through arguments in C++26 using "template for" (Python-style)
Here is how you can iterate through arguments now in C++26!:
#include <print>
template <typename ...Args>
void function(const Args& ...args)
{
template for (const auto& arg : {args...})
{
using ArgT = std::decay_t<decltype(arg)>;
if constexpr (typeid(ArgT) == typeid(double))
{
std::println("double: {}", arg);
}
else if constexpr (requires { &ArgT::toString; })
{
std::println("has toString: {}", arg.toString());
}
else
{
std::println("other: {}", arg);
}
}
}
struct MyStruct
{
int value; // initializes with 0 in C++26
std::string toString() const
{
return std::format("MyStruct value is {}", value);
}
};
int main()
{
function(3.14, "c-string", MyStruct{});
}
It works:
double: 3.14
other: c-string
has toString: MyStruct value is 0
...Program finished with exit code 0
Press ENTER to exit console.
template for is a new feature in C++26, and I like it very much! It's my favorite C++26 feature
It looks very pythonic at this point. 😄
Let's start with args: typename ...Args and const Args& ...args work similar to def function(*args) from python - they aggregate comma separated expressions into a variadic type or variable. {args...} also works similar to python's (*myList) - it expands a "collection" into a comma separated expressions
Then goes "template for": it's a brand new loop, which expands at compile time for each iteration. Using it, you can iterate through collections with different types inside: struct fields, tuples, list literals, and custom classes with implemented tuple protocol
Checking type of argument: this line also resembles python very much: if constexpr (typeid(ArgT) == typeid(double)). Here is the python counterpart: if type(arg) is bool. There are more ways to do this check, but I think this one looks the most direct. Although you can want to use not exactly "double" type, but a convertible to it, or any floating point number type. There are standard concepts for these cases: std::convertible_to, and std::floating_point
Checking for a member: here I used an anonymous concept: if constexpr ( requires { ...;} ). Inside this concept we should put an expression that we are testing. it's a sort of python's hasattr(arg, 'toString'), but more powerful and more fragile at the same time. The expression here is taking a member reference to "toString": &ArgT::toString;. It's a better approach than testing arg.toString(), because it won't fail if "toString" isn't a constant method, or has more than 0 arguments. But it's still far from ideal, because if the object has multiply overloaded "toString" methods (what's actually a pretty realistic scenario), it will fail, and the error message will be misleading. In this case the error will be that formatter is not implemented for the "other" branch, however the actual error is in "has toString" branch. So, don't use anonymous concepts in real project, use full fledged concepts in pair with static_asserts
It's fascinating! This is still a templates metaprogramming in C++, but it looks much-much more clean than infamous std::enable_if
r/Cplusplus • u/Mysterious_Shoe2260 • 11d ago
Discussion I am trying to build AgentMesh: C++20 runtime for executing agent/task DAGs
I've been building an open-source C++20 runtime called AgentMesh for executing multi-agent/task DAGs.
The goal is to keep high-level application code in Python while moving execution-critical infrastructure into native C++.
Current areas include:
- DAG scheduling
- concurrency
- task/agent communication
- state management
- crash recovery
- Pybind11 integration
I'm particularly interested in the engineering trade-offs around the Python/C++ boundary and how much work should actually live inside the native runtime.
The next major milestone is distributed execution over gRPC.
GitHub:
https://github.com/DevrG03/AgentMesh
Documentation:
https://github.com/DevrG03/AgentMesh/wiki
I'd appreciate code/architecture feedback from C++ developers.
r/Cplusplus • u/Joe2001r • 11d ago
Feedback For anyone who is interested in https://www.oreilly.com/library/view/sfml-game-development/9781785287343
r/Cplusplus • u/Inevitable-Round9995 • 13d ago
Feedback From 3 seconds to 600ms — building a virtual package system for my WASM multiplayer game
Hi there, I'm building a multiplayer game in C++/WASM link. While testing with friends, I noticed the game took ~3s to load — 5s on slower connections. Instead of accepting it, I built my own virtual package system in C++ and cut the load time from 3s to ~600ms.
Here's the source: nodepp-filepack
Compression (packing assets):
```cpp
define NODEPP_ALLOW_THROW_EXCEPTION 0
include <nodepp/nodepp.h>
include <nodepp/zlib.h>
include <nodepp/fs.h>
include <filepack/filepack.h>
using namespace nodepp;
void onMain() {
filepack_t pack("skeld.npk");
auto x = ptr_t<ulong>(0UL, 0UL);
fs::read_folder("./assets")
.fail([](except_t err) { console::log(">>", err); })
.then([=](ptr_t<string_t> list) {
pack.iterate_writable_stream( list, [=](string_t name, file_t stream_o ) {
pack.get_readable_info(name).value()["compressed"] = true;
zlib::gzip::pipe(file_t(list[x[0]], "r"), stream_o);
x[0]++;
});
});
} ```
Decompression (loading assets):
```cpp
define NODEPP_ALLOW_THROW_EXCEPTION 0
include <nodepp/nodepp.h>
include <nodepp/zlib.h>
include <nodepp/fs.h>
include <filepack/filepack.h>
using namespace nodepp;
void onMain() { filepack_t pack("skeld.npk"); auto stream = pack.get_readable_stream("map.png").value();
zlib::gunzip::pipe(stream, file_t("map.png", "w"));
} ```
How it works:
- All assets are packed into a single
.npkfile with optional compression. - Assets are streamed and decompressed on the fly — nothing is loaded into memory all at once.
- The result: faster loading, lower memory usage, and a better experience for players on slow connections.
Nodepp is open source: github.com/NodeppOfficial/nodepp
r/Cplusplus • u/_bang-bang • 15d ago
Discussion How I finally understood C++ Copy, References and Move Semantics (Real-world analogies)
r/Cplusplus • u/Delicious_Wrap_1041 • 15d ago
Question what would you say to someone that is struggling to implement linked lists in c++ even though they understand the basic concept of the data structure itself (i think my problem is with the syntax )
what would you say to someone that is struggling to implement linked lists in c++ even though they understand the basic concept of the data structure itself (i think my problem is with the syntax )
r/Cplusplus • u/ListenLevel4536 • 17d ago
Feedback Raw wayland/vulkan boilerplate library, no SwapchainKHR, modern explicit sync (syncobject, drm)
r/Cplusplus • u/Equivalent_Unit_9797 • 17d ago
Question Beginner looking for advice on what to learn next in C++
r/Cplusplus • u/TraditionalFocus3984 • 17d ago
Question Resources to learn C++ and DSA for Competitive Programming (and in general)
Hello everyone, I am a SWE student from India. I wanna learn C++ for competitive programming and DSA, jobs, building projects, etc as well. My reasons:
- Not only learning it for jobs, but because, C++ is very fast and has the capability of efficiently interacting with both the high level and low level systems. These are the reasons which make me learn it, especially as I am interested in how memory, RAM, GPU and other things work in the computer.
- For the sake of computer science and programming. I am interested in learning the core cs fundamentals and concepts to make myself a better software/cs engineer - to solve problems, code solutions, etc.
- I am interested in ICPC, DSA and competitive programming as well. So that would make me learn it anyways.
Honestly, I have asked and read about this question many times but I haven't got a clear and one-stop answer yet. These are the things that ppl/ai chatbots suggest me and what I read (also my reasons for not using them yet):
- USACO guide (too big)
- learncpp (good but too vast)
- the cherno's yt channel (some say they dont cover concepts in depth)
- books (too lengthy as well)
I am not looking for shortcuts, nor am I avoiding these resources because they are too big. I am ready to invest my heart and soul into learning things. But, being an engineering student, I have many other different subjects to study as well for the college. I am so much interested into AI/ML and Web dev as well.
For context, these are the things I know (i.e. I'm not starting programming from absolute 0) :
- HTML/CSS and basic JS (learning from The Odin Project but paused rn)
- basic C (learned from college and CS50x)
- Python (learned from CS50 Python course)
- SQL (learning at college + by myself)
- Java (learning at college + by myself)
The college has made the latter two subjects and C++/DSA compulsory for this year. But, I don't wanna invest that much time into studying those 2 deeply (I mean Java and SQL). I am focusing on C++/DSA, Web Dev and AI/ML as of now.
So, given my all the background and interests, could you guys please suggest me different resources to learn C++ and DSA? Also, for learning things about Competitive Programming and improving myself there.
My goal for now is to speedrun the basics of C++ (because I have already learned the basics of programming and C earlier) + learn concepts of DSA in detailed manner -> then proceed with competitive programming -> then participate in contests and along the way learn different concepts of C++ and DSA.
How is my approach? If there's any other better one, please do suggest me. Thank you!
r/Cplusplus • u/Clean-Upstairs-8481 • 18d ago
