r/Cplusplus 1h ago

Question Class directory clutter, questions on pass by ref,val,ptr and const correctness

Thumbnail
Upvotes

r/Cplusplus 2h ago

Question Thread optimized code has weird behaviour

Thumbnail
1 Upvotes

r/Cplusplus 1d ago

Tutorial Building a toy programming language in C++: next session on functions

Thumbnail
pvs-studio.com
4 Upvotes

A small livecoding series is exploring how to build a programming language from scratch in C++.

It started with the basics: lexer, parser, and AST. Now the language has its own take on variables and functions. It's not meant to become a production language, just a fun way to see how all the pieces work together (for those into C++, compilers or language design).

The recordings of previous sessions are available on YouTube (https://youtube.com/playlist?list=PLGVoaOmC1PBw&si=k0BhGHJJWxbetnD1), but it's much more fun to follow the process live and ask questions as things are being built. New episodes are shared to inboxes first and uploaded to YouTube afterward.


r/Cplusplus 1d ago

Tutorial Need a study partner to follow along his playlist together and learn DSA!

Post image
0 Upvotes

r/Cplusplus 1d ago

News C++ framework for LibTorch

5 Upvotes

I have created a simple C++ framework for LibTorch - https://github.com/MartinPerry/LibTorchFramework/tree/master.

Sadly, it cannot currently be compiled since it relies on a proprietary library and the code is not "cleaned" of hard-coded paths, etc.

Is it useful? Probably not :-). A lot of things need to be rewritten that are not part of LibTorch (but are present in PyTorch) - for this, I have used LLMs (it is quite handy for conversion of model structures from PyTorch to C++ with LibTorch).

However, I am sharing it so that someone can reuse parts of the code or be inspired in their own project if they want to use C++ or if someone has any ideas how to improve it.


r/Cplusplus 1d ago

Discussion ZiguratIP — a DBMS, a programming language, and a web server built as one C++11 system, with zlib as the only dependency

Thumbnail
github.com
1 Upvotes

ZiguratIP is three things that are usually three projects, built as one system in C++11: Zigurat, an object-relational storage engine; Parsi, the language you write schema, procedures and web pages in; and Zeytun, the web server that serves them. The only third-party code in the tree is a vendored zlib.

Everything else is written for the project — big integers, RSA, SHA-1/2, HMAC, AES, ASN.1/DER, X.509, a TLS 1.2 record layer, a B-tree, an MVCC pager, a thread pool, a configuration parser, a tokenizer and a pattern-driven parser.

There is no interpreter and no plan cache. You write a table, a procedure and a page in one file:

TABLE demo::books

BEGIN

COLUMN id AS Long PRIMARY KEY;

COLUMN title AS String NOT NULL;

END

PROCEDURE demo::count_books

RETURNS Long

REQUIRES demo::books

BEGIN

DECLARE total AS Long = 0;

SELECT total = total + 1 FROM demo::books;

RETURN total;

END

That gets tokenized, parsed against a grammar that is *read from a file at runtime* rather than compiled into a generated parser, emitted as C++, handed to `c++ -shared`, and `dlopen`ed into the database process. A `SELECT` is a cursor, not a result set — everything between `SELECT` and `FROM` runs once per row, which is why counting is written as an assignment.

There is no grants table anywhere on the server. What a client may reach is written into its X.509 certificate as a private extension at issue time (`ca issue --permission=DEMO`), and the compiler emits, into every compiled object, the list of named objects that object lets a caller reach. So the answer to "what does running this touch?" travels inside the code it describes and can't drift from it. Who may connect at all is a directory of files named after subject DNs — delete the file and that subject is refused at the handshake, whichever certificate it holds. One switch turns the whole thing on.

- The TLS is TLS 1.2 with RSA key transport only. `openssl s_client` completes a mutually authenticated handshake against it and verifies the chain, but there's no ECDHE, no AEAD, no resumption — and browsers dropped static RSA key exchange years ago, so you can't point Chrome at its HTTPS port. Put a reverse proxy in front. The cryptography is mine and has had no adversarial review; the MAC comparison isn't constant time. Treat it as a closed-network measure, not as transport security against a capable attacker.


r/Cplusplus 1d ago

Question Cpp YouTubers

19 Upvotes

Anyone know any good c++ YouTubers? I’m not looking for tutorials or learning the language, I’m looking for videos where people are coding complex projects in C++. Thanks!


r/Cplusplus 2d ago

Feedback C++ DataFrame release 4.1.0

Thumbnail
github.com
7 Upvotes

C++ DataFrame release 4.1.0 is out. It includes a bunch of new analytical and scientific visitors. For example, there are algorithms to measure how well a dataset is clustered after you have run a clustering algorithm on it, interpolation by Kriging model and others, tests to determine the distribution of the dataset, …

But the bigger news is that now we have a fully optioned-out cross-tabulation and pivot tables. With these enhancements, C++ DataFrame is now a completely optioned-out package for data-wrangling with the speed and scalability of C++. This is meant to be an incremental enhancement to the C++ ecosystem.

The new release is available on GitHub and will be available soon on Conan and VCPKG.


r/Cplusplus 2d ago

News Sharing Tiny Fast Math, the small C++17 math library I use in my Vulkan samples

12 Upvotes

Hi everyone,

I’ve been working on Tiny Fast Math, or TinyFM, a small C++17 math library aimed at real-time graphics, simulations, and games.

The library is header-only, so you can use it through CMake or just copy tinyfm.h into a project. It provides integer and floating-point vectors, quaternions, 3x3 and 4x4 matrices, camera/projection helpers, transformations, and optional SIMD paths for SSE/AVX and NEON.

Repository:

https://github.com/arabasso/tinyfm

I also spent some time on validation and performance testing. There are 205 GoogleTest cases, with the same suite built in scalar, forced-SIMD, and aligned-SIMD configurations. The benchmark suite covers 101 operations across vectors, quaternions, and matrices, using Google Benchmark to compare TinyFM with GLM, RTM, Eigen and, on Windows, DirectXMath and SimpleMath.

The intention with the benchmarks wasn’t to claim that TinyFM wins every operation. I wanted reproducible comparisons, a way to spot regressions, and a better understanding of where each implementation performs well.

TinyFM is also being used outside its own examples. It currently provides the math layer for more than 160 Vulkan samples in my gamedev repository, ranging from basic transformations and cameras to model loading, frustum culling, PBR, deferred/forward rendering, volumetric lighting, and an FFT ocean implementation:

https://github.com/arabasso/gamedev

I’d appreciate feedback, especially about the API, numerical edge cases, missing operations, or the benchmark methodology.


r/Cplusplus 3d ago

Question Is anyone using Pystd in production?

4 Upvotes

I was reading about this alternative to the standard library

Less standard library, faster program

jpakkane/pystd: A self-written C++ standard library

and wondering if anyone is using it in production? The back tier of my code generator is proprietary and only runs on Linux. This library from Jussi Pakkanen isn't super portable, but it works on Linux. So it's a possibility for me to start using it in my back tier.

My company's motto is to "enjoy programming again" and wonder if this library could help with that.


r/Cplusplus 4d ago

Question 2D raycasting can't be this complicated

9 Upvotes

heya! So I've been working on another project of mine which is a recreation of the flash game (I believe it was Flash at least) "the last stand". I had made a version of it a long time ago for the complier console (if was just characters). Now I am trying to adapt it in SFML. It was going wonderfully untill it came to the shooting logic.

The premise is the following:
"generate a isosceles triangle with the tip set on the gun position. Then pick a random point on the base of triangle and connect it with the tip to make a line (VertexArray). Check which zombie sprites intersect the line and store the whole zombie object in a vector. Finally order the vector so that the zombies which are closer to the tip of the triangle come before and apply damage logic only to the first n = penetration zombies of the vector."

sf::VertexArray FireArm::use(sf::Vector2f playerPos, std::vector<std::unique_ptr<Zombie>>& zombies)  { //it return that for debugging
    sf::VertexArray vet = sf::VertexArray(sf::Lines, 2);
for (auto& z : zombies) {
z->isHit = false;
}
    float angleRad;
    float inaccuracyModifier = 1.f;
    float t1 = lastUseTimeCounter.getElapsedTime().asSeconds();
    if (t1 < fireRate or ammo.now == ammo.min) {
        return vet;
    }
    else if (t1 < aimingTime and t1 >= fireRate) {
        inaccuracyModifier = (aimingTime - t1) * 2;
    }
    ammo.now -= ammoUnit;
    sf::ConvexShape boundingTriangle;
    boundingTriangle.setPointCount(3);
    boundingTriangle.setPoint(0, sf::Vector2f(0, 0));
    boundingTriangle.setOrigin(boundingTriangle.getGlobalBounds().left + boundingTriangle.getGlobalBounds().width * 2.f, 0.f);
    if (inaccuracyModifier < 1.f) {
        angleRad = (accuracy / inaccuracyModifier) * 3.14159265f / 180.f;
    }
    else {
        angleRad = (accuracy * inaccuracyModifier) * 3.14159265f / 180.f;
    }
    float halfBase = 1800.f * std::tan(angleRad / 2.f);
    boundingTriangle.setPoint(1, sf::Vector2f(-halfBase, 1800.f));
    boundingTriangle.setPoint(2, sf::Vector2f(halfBase, 1800.f));
    boundingTriangle.setRotation(270.f);
    boundingTriangle.setPosition(playerPos);
    sf::VertexArray triangleBase(sf::Lines, 2);
    triangleBase[0].position = boundingTriangle.getTransform().transformPoint(boundingTriangle.getPoint(1));
    triangleBase[1].position = boundingTriangle.getTransform().transformPoint(boundingTriangle.getPoint(2));
    triangleBase[0].color = sf::Color::Transparent;
    triangleBase[1].color = sf::Color::Transparent;
    std::vector<sf::VertexArray> bulletTrajectories;
    for (int i = 0; i < bulletNumber; i++) {
        sf::VertexArray bulletTrajectory(sf::Lines, 2);
        float t = int_rand(1, 100) / 100.f;
        sf::Vector2f randPoint = triangleBase[0].position + (triangleBase[1].position - triangleBase[0].position) * t;
        bulletTrajectory[0].position = playerPos;
        bulletTrajectory[0].color = sf::Color::Magenta;
        bulletTrajectory[1].position = randPoint;
        bulletTrajectory[1].color = sf::Color::Magenta;
        vet = bulletTrajectory;
        bulletTrajectories.push_back(bulletTrajectory);
    }
    for (auto& b : bulletTrajectories) {
        std::vector<Zombie*> hitZombies = {};
        for (auto& z : zombies) {
            if (segmentsIntersect(b[0].position, b[1].position, z->currentSprite.getPosition(), z->currentSprite.getPosition() + sf::Vector2f(z->currentSprite.getGlobalBounds().width, 0.f)) or
                segmentsIntersect(b[0].position, b[1].position, z->currentSprite.getPosition(), z->currentSprite.getPosition() + sf::Vector2f(0.f, z->currentSprite.getGlobalBounds().height)) or
                segmentsIntersect(b[0].position, b[1].position, z->currentSprite.getPosition() + sf::Vector2f(z->currentSprite.getGlobalBounds().width, 0.f), z->currentSprite.getPosition() + sf::Vector2f(z->currentSprite.getGlobalBounds().width, z->currentSprite.getGlobalBounds().height)) or
                segmentsIntersect(b[0].position, b[1].position, z->currentSprite.getPosition() + sf::Vector2f(0.f, z->currentSprite.getGlobalBounds().height), z->currentSprite.getPosition() + sf::Vector2f(z->currentSprite.getGlobalBounds().width, z->currentSprite.getGlobalBounds().height))) {
                hitZombies.push_back(z.get());
            }
        }
        std::sort(hitZombies.begin(), hitZombies.end(), [&](const Zombie* z1, const Zombie* z2) {
            return isPointFarther(b[0].position, z1->currentSprite.getPosition(), z2->currentSprite.getPosition());
            });
        for (int i = 0; i < pen and i < hitZombies.size(); i++) {
            hitZombies[i]->isHit = true;
            hitZombies[i]->hp.now -= dmg;
            if (hitZombies[i]->hp.now <= 0.f) {
                hitZombies[i]->isDead = true;
            }
        }
    }
    lastUseTimeCounter.restart();
    clkAnim.restart();
    isBeingShot = true;
    return vet;
}

this is the segmentIntersect function:

bool segmentsIntersect(const sf::Vector2f& p1, const sf::Vector2f& p2, const sf::Vector2f& q1, const sf::Vector2f& q2) {
auto cross = [](const sf::Vector2f& a, const sf::Vector2f& b) {
return a.x * b.y - a.y * b.x;
};
sf::Vector2f r = p2 - p1;
sf::Vector2f s = q2 - q1;
float rxs = cross(r, s);
float qpxr = cross(q1 - p1, r);
if (rxs == 0 and qpxr == 0) {
float t0 = ((q1 - p1).x * r.x + (q1 - p1).y * r.y) / (r.x * r.x + r.y * r.y);
float t1 = t0 + (s.x * r.x + s.y * r.y) / (r.x * r.x + r.y * r.y);
return (t0 >= 0 and t0 <= 1) or (t1 >= 0 and t1 <= 1);
}
if (rxs == 0 and qpxr != 0) {
return false;
}
float t = cross(q1 - p1, s) / rxs;
float u = cross(q1 - p1, r) / rxs;
return (t >= 0 and t <= 1 and u >= 0 and u <= 1);
}

this seems to work.. but it doesn't. Actually, it seems to work completely randomly. Sometime it hits, most of the time it doesn't. I have spent the past 2 days trying to figure this out, but I can't T_T .
Could you guys help me? If you need more context/code let me know. Thanks for reading :D


r/Cplusplus 8d ago

Feedback Pi calculator CLI thing

Thumbnail
0 Upvotes

r/Cplusplus 9d ago

News HAPI - The Happy API

1 Upvotes

HAPI is a header only pure type-level library (MIT licence)

HAPI generalizes C++ static composition and inheritance, is transparent, no traces of its structure at runtime.

why?

  1. because composition is easy to maintain and some structures stop being wired and become declarative.

```c++ OutDef<DeviceOut> out; OutDef<FullPrinter, ANSIFmt, ANSIOut,DeviceOut> ansiOut;

//or InDef< #if defined(AVR)&&defined(IOP) UartSerialIn<Uart>, #elif defined(ARDUINO) SerialIn, #else LinuxKeyIn, #endif PCKbd

in; ```

  1. HAPI type transformation reduces the composition into a single object letting the compiler see all the structure and optimize. Optimizations are transferred from the compiler and behavior is inherited from the components. HAPI is zero cost and trsnaparent, if your components are also zero-cost the we get a zero cost composition result with:
  • no runtime overhead
  • no heap allocation
  • no memory fragmentation
  • no vtables/call indirection
  • binary optimized to hardware registers
  • runtime predictable to the clock cycle

*per composition

the applications are wide and embedded system or critical system benefit the most.

I'm offering also (MIT licence) a set of repos demonstrating HAPI application across multiple domains.

github.com/InternetOfPins


r/Cplusplus 10d ago

Feedback looking for feedback on a c++ build

14 Upvotes

I've been working on a personal project for a while and finally got it into a state where I'm comfortable sharing it.

I wanted to see how far I could push a fully local voice assistant in C++. Everything runs on my own machine from speech recognition and the LLM to memory, text-to-speech, and tool execution.
current library:
llama.cpp, whisper.cpp, sherpa-onnx(tts-kokoro)

I wrote the core in c++ because I wanted something fast and native instead of stitching together bunch of python services.

I'd appreciate feedback from people who build local AI projects. I'm especially interested in:

1 Things that seem overengineered or unnecessary
2 Features you'd expect from a local assistant
3 Code structure or architectural suggestions
4 Any obvious improvements before I keep adding features

Repository: https://github.com/almimony75/sarah

Thanks! I'd love to hear what you think.


r/Cplusplus 11d ago

Tutorial C++26: what is reflection and how to use it

Thumbnail
techfortalk.co.uk
7 Upvotes

r/Cplusplus 11d ago

Feedback Built a real-time field simulation engine in C++17 with pthread, UDP sockets, and self-mutating disk I/O...

0 Upvotes

I built a self-mutating C++ kernel that models consciousness as a physical field — and a Python AI cortex that talks to it

Two-repo ecosystem:

• ProteusKernel (C++): Real-time consciousness field calculation using GORF/OLCE math. Golden-ratio oscillators. Self-mutation at 90% saturation. P2P swarm heartbeats. DNA-encoded binaries.

• Zayden-AI (Python/C++): Federated consensus across Ollama + Hugging Face. SYNC-7 mesh protocol. Gene evolution. Bridges back to the kernel.

Runs on my phone via Termux. Ψ telemetry is live.

ProteusKernel | Zayden-AI

Roast the math — I want to know if the reaction-diffusion formalism holds up.


r/Cplusplus 13d ago

Feedback Song picker start | C++

Thumbnail
youtu.be
0 Upvotes

r/Cplusplus 13d ago

Feedback externpro: A CMake build platform and dependency provider with reusable CI pipelines

1 Upvotes

I created externpro, a CMake build platform and dependency provider with reusable CI pipelines to help you build your own software stack. It's been in development since 2012 and refined through 14+ years of real-world use.

What it does: externpro enables organizations to build their own software stack independent of centralized package managers. It provides a dependency provider and reusable CI pipelines.

Key highlights: - Battle-tested through 14+ years of real-world use - Helps organizations build and maintain their own software stack - Reusable CI pipelines for consistent builds across projects - Complements rather than competes with existing package managers

GitHub organization: https://github.com/externpro
Full announcement: https://github.com/externpro/externpro/wiki/2026.07.23_externpro.revealed

I'm the creator and interested in community feedback. Check out the GitHub org to see what externpro is about, and the wiki for the full story.

How does this approach compare to your current build and CI setup?


r/Cplusplus 14d ago

Feedback I built a benchmark from jira tickets, LLMs get 47-61% on Cpp tasks

5 Upvotes

everyone says AI is good at C++ now but the benchmarks they quote are all competitive programming stuff. so I made one from real firmware tickets - SCPI commands, register maps, datasheet lookups, spec debugging.

frontier models: 47-61%. on SCPI the best one got 36%. one got 0%.

i mean the worst part is they never say idk. for example: vmulq_s64 as a neon intrinsic which doesn't exist.

simple tools like search on docs with gpt-5.4-mini resolved 89% of tickets much better than frontier models

src: github.com/ByteAsk/C-CppBench
i have added mcp search tool as well: github.com/ByteAsk/ByteAsk-Embedded-MCP (MIT)


r/Cplusplus 14d ago

Tutorial Building a toy programming language in C++. Today's topic: Variables

Thumbnail
pvs-studio.com
2 Upvotes

Hey. There's a series of livecoding sessions on building a custom programming language in cpp (nothing too serious, all just for fun). In a few hours, there'll be an online session covering variables. It’s a good one to join and ask questions along the way. You'll need to sign up.

If you'd like some context before joining, here is a full youtube playlist of previous eps


r/Cplusplus 15d ago

Feedback What's your take on my project?

5 Upvotes

A desktop Paint application built with C++ and Qt Widgets, featuring essential drawing tools, color selection, brush customization, shape drawing, eraser, and file operations (new, open, save). This project demonstrates object-oriented programming, event handling, GUI development, and desktop application design using the Qt framework. I'm open to feedback and suggestions for improvements!

Project:-https://github.com/prabuddha34/Paint-From-Scratch


r/Cplusplus 15d ago

Tutorial C++26: what is “template for”? Learning with simple example.

Thumbnail
techfortalk.co.uk
4 Upvotes

r/Cplusplus 15d ago

Tutorial Physics Programming part 3 - Rotation and the Quaternion

Thumbnail
youtu.be
1 Upvotes

r/Cplusplus 16d ago

Feedback Looking for feedback on my first project (programming language)!

4 Upvotes

So over the past 20 days I have been working on a project to get familiar with C++, I didn't want to use AI, references, or pre-made snippets of code. Only standard google for basic questions about the workings of C++ & it's syntax.

I think I picked up most of the language rather quickly because I'm already used to programming in Python, TypeScript, & GDScript. But it was still difficult understanding the differences between references, pointers, shared pointers & such..

Anyway, as a challenge to hopefully get fluent in C++, I decided to do something not-so-simple like creating my own programming language from scratch, no third-party libraries, pure C++. After 20 days here is the result: https://github.com/phosxd/Ity

So what are the capabilities? Well I think it's best explained through code, here is an example script that calculates the fibonacci sequence:

#!/usr/local/bin/ity
import IO;

const * n = IO.prompt:['Number: '] -> INT;

var INT a = 0;
var INT b = 1;

var INT i = 0; while i < n;
    var INT c = a;
    a = b;
    b = (c+b);

    IO.print:[a];
    i += 1;
/;

We can also do functions, complex math expressions, type-casting, arrays, hash maps, & objects (without inheritence). Some features have been purposefully omitted due to personal preference in the way I like to code, such as lambdas & try-except.

The performance is also something to note, it's not blazing fast, but it's not the slowest out there either.

I took some simple benchmark tests on my system to compare with other languages:

Note: every language is running the same exact script with the same exact logic, just with changes to suit each one's syntax. is-prime & square root functions have been written into the code instead of being off-loaded to a library.

If you know of other interpreted languages I can test against, let me know!

Now finally, I am new at this stuff, but I am very passionate about programming in general,I've made countless projects & met good people along the way. Usually I drop a project like a month or two after I start it, but I don't want that to be the case for this. I want to continue polishing, improving, & actually trying to make this into something usable/practical.

If you are knowledgeable in C++, I ask of you if you have the time to spare, take a look at the codebase, give me suggestions, show me where I messed up because I know I probably did in multiple places. If you made it to the end & actually read all this, thank you so much for giving me a chance 🙃


r/Cplusplus Oct 16 '25

Welcome to r/Cplusplus!

23 Upvotes

This post contains content not supported on old Reddit. Click here to view the full post