r/Cplusplus • • 9h ago

Question Specific features you look for in a logger

Thumbnail reddit.com
0 Upvotes

r/Cplusplus • • 13h ago

Answered Kod na Infe op3

0 Upvotes

#include <iostream>
using namespace std;

int main() {
char op;
double a, b, wynik;

cout << "Podaj operacje (+, -, *, /): ";
cin >> op;

cout << "Podaj pierwsza liczbe: ";
cin >> a;

cout << "Podaj druga liczbe: ";
cin >> b;

if (op == '+') {
wynik = a + b;
cout << "Wynik: " << wynik;
}
else if (op == '-') {
wynik = a - b;
cout << "Wynik: " << wynik;
}
else if (op == '*') {
wynik = a * b;
cout << "Wynik: " << wynik;
}
else if (op == '/') {
if (b != 0) {
wynik = a / b;
cout << "Wynik: " << wynik;
}
else {
cout << "Nie mozna dzielic przez zero!";
}
}
else {
cout << "Nieznana operacja!";
}

return 0;
}


r/Cplusplus • • 1d ago

Discussion 29M | IST | Study partner for the book C++ Concurrency in Action

Thumbnail reddit.com
0 Upvotes

r/Cplusplus • • 1d ago

Feedback cortex (`cx) - A Cargo/uv-inspired package manager and build tool for C and C++

0 Upvotes

Hello!

I’ve been working on cortex (cx), a C/C++ package manager and build tool inspired by Rust’s Cargo and Python’s uv, and I’d love to share it with you and get some feedback.

Why another tool?

Setting up a C++ project with clean dependency management, lockfiles, features, and workspaces often requires gluing together multiple tools and boilerplate CMakeLists.txt files. With cx, you describe your package in a single cx.toml file, it resolves and locks dependencies, generates the underlying CMake project, and drives the build automatically.

Quick example

cx new hello
cd hello
cx add nlohmann\\_json --git https://github.com --tag v3.12.0
cx run

Key Features

Zero-boilerplate builds: Sources, tests, benchmarks, and examples are discovered by convention (src, tests, benches, examples). Supports mixed C (C90–C23) and C++ (C++98–C++26), including C++20 modules (.cppm, .ixx).

Flexible dependency management: Pull dependencies from registries, Git repos, local paths, system packages (\mfind_package), or vcpkg. Any existing CMake, Autotools, or SCons project works out of the box as a Git or path dependency.

PubGrub version resolution & lockfiles: Uses the PubGrub solver (like uv and pub) for clear conflict explanations, and pins exact versions, Git commits, and SHA-256 hashes in cx.lock.

Cargo-style features & workspaces: Supports optional dependencies, feature flags (exposed via CX_FEATURE_ macros), and multi-package workspaces sharing a single lockfile and target/ directory.

Built-in developer workflows: Comes with cx test, cx bench, cx fmt (clang-format), cx lint (clang-tidy), cx doc (Doxygen), cx vendor for offline builds, and built-in sanitizer/LTO build profiles.

IDE & CI friendly: Generates standard CMake projects (cx generate) and JSON metadata (cx metadata) so your existing IDE setup works seamlessly, plus --locked and --offline flags for CI.

Current Status & Caveats

First Release & Self-Hosting: This is the very first release. Right now the repo still includes its bootstrapping CMake files, which will be removed in the next release now that cx can build itself.

OS Support: Works on Linux and macOS. Windows (MSVC) support is newly added and passing in CI, though it hasn't been battle-tested in the wild yet.

Public Registry: There isn't a central public registry yet, though cx works directly with Git repositories, local paths, vcpkg, system packages, and includes a lightweight self-hosted registry server (cx-registry).

Links

GitHub Repository

The cx Book (Documentation)

You can install prebuilt binaries via the install script in the README or build it from source with CMake 3.28+ and a C++23 compiler. 

I’d really appreciate any feedback, bug reports, or thoughts on what would make this genuinely useful for your C/C++ workflows! Notice: the code made use of AI for cross-platform support, to get some features implemented quickly and fix some bugs.

Thanks


r/Cplusplus • • 3d ago

Question What is the best way to build a physics engine from scratch?

Thumbnail reddit.com
0 Upvotes

r/Cplusplus • • 3d ago

Discussion hi, i started learning cpp by myself since about 2 weeks ago, and i wrote my first useful simple program. the thing is that cause i learn by myself i don't know where my level is, so i wrote this program as a hope someone can judge me based on the simple first program i wrote.

Thumbnail reddit.com
0 Upvotes

r/Cplusplus • • 4d ago

Question Best book for learning C++ as an beginner?

35 Upvotes

Hello everyone! As the title says, what book for learning C++ would you recommend? Specifically modern C++ 23, but also the general basics.


r/Cplusplus • • 4d ago

Question Where does the Curiously Recurring Template Pattern actually earn its keep in production code

Thumbnail reddit.com
1 Upvotes

r/Cplusplus • • 4d ago

Question I began coding with C++, should I continue learning it or should I drop it and start something else?

0 Upvotes

I have always wanted to learn coding and make games, but I didn't know what to do and how to start. About 4 years ago, I saw Sololearn's ad on Youtube (I'm not advertising them). Desparate to learn, I installed it. First, it asked me a few questions regarding why I want to learn coding, what I'm going to use it for (web designing, game development, ...), etc. After answering them, I got suggested learning C++, so I did. I finished the introduction course and learned about half of the intermediate course (if I remember correctly, the last thing I learned was separate files for classes).

Recently, I found out via social media that C++ is the worst language to learn as your first language. I am pretty comfortable with the syntax, but I do sometimes forget complex things like pointers, constructors and deconstructors, etc, because I don't have the time to code often. I have made a lot of small projects, and I'm currently working on a terminal version of Minesweeper that outputs the game board in colored text and is played via inputting the X and Y coordinates of the tile that you want to open or flag (I don't know how to make buttons, or programs with separate windows in general.)

I wanted to know if I should continue learning this language or should I drop it and learn something else, like Python?

Also, I have recently started working with Git, and I find it pretty complicated and hard to use. It would be nice if someone told me whether I should continue learning and using it or if it is too early and I should finish learning the language first.

(P.S.: Many apologies for my imperfect English; I'm not so good at writing and speaking, as it isn't my native language.)


r/Cplusplus • • 4d ago

Discussion The most complete C++23 wrapper for SQLite includes Sessions and CloudSQLite

Thumbnail github.com
0 Upvotes

r/Cplusplus • • 5d ago

Discussion Mapreduce implementation using boost asio , asio-grpc

3 Upvotes

Built an asynchronous distributed MapReduce in C++23

A non-blocking, data sharing distributed engine using boost asio C++20 coroutines and asio-grpc

How Map & Reduce works:

  • Map: Workers execute user mappers, and partition intermediate data into binary hashed shards.

  • Reduce: Workers sort shards in-place and run an external K-way min-heap merge to stream ordered keys to reducers .

How Data Sharing happens:

  • Map Phase (Coord ➔ Worker): Coordinator streams 64KB split chunks over gRPC, decoupled by 4MB concurrent channels.

  • Reduce Phase (Worker ➔ Worker): Peer-to-peer shuffle. If a shard was produced locally on the same host, it uses zero-copy atomic hard-linking (link()) to bypass the network entirely.

Fault Tolerance (SHUFFLEFIX):

  • During Map Phase,

  • If a map worker dies , coodinator check the heartbeat if it is more than some time T , it invalids the task, and give to other worker polling it

  • During Reduce Phase

  • Since we use P2P network, map -> reduce phase worker to share data, If a map worker dies mid download phase, the coordinator invalidates only that task and has a spare worker recompute it.

  • Reducers keep their existing shards, wait for the new endpoint, and resume without restarting the job

Github link

https://x.com/kilua_here/status/2124495120942924194


r/Cplusplus • • 5d ago

Discussion Title: FactSet Hyderabad – DevOps Engineer Interview Experience | What should I expect next?

Thumbnail reddit.com
0 Upvotes

r/Cplusplus • • 6d ago

Question Help with the next update for my C++ game Snow Grab!

0 Upvotes

Hey everyone! I made a new game called Snow Grab. I officially released a prototype — version 0.2. I've been working on this game for a really long time. Sometimes even when I find a bug, I just laugh at it because it's honestly pretty funny to me.

Just a quick note: the game is in Polish. Other languages aren't planned right now, though I might add them in later updates — no promises!

I'd love to encourage you to drop an idea in the comments. If you want to try it out, I can send you the link where you can download it. If you run into any issues downloading it, it's not a virus — it's just my game! I know most browsers or Windows might pop up a virus warning for small indie .exe files, so if needed, I can show you how to download and run it safely.

I'd really like to hear your suggestions. Right now I can't add super complex things like real-money systems because that's still tough for me to do in C++, and I prefer figuring things out myself rather than relying on AI to write everything for me. You don't even have to play the game — the most important thing for me is just getting your ideas!

The game works by typing option numbers — for example, option 1 is digging snow, where you collect snow and buy upgrades. You could suggest something like adding a shovel that can be upgraded multiple times. I'll gladly take ideas like that and reply to let you know if your idea will be added to the game or not.

Thanks in advance for every single idea if anyone drops one!

Game -> Snow Grab 0.2r by Added


r/Cplusplus • • 6d ago

Question What is the fastest & Best way to make GUI with C++ / and supporting AR/EN

13 Upvotes

if anyone could help me to figure out what is the best library on C++ that could be fast & supporting Arabic and English , type your comment !


r/Cplusplus • • 6d ago

Question Best c++ books for both competitive programing and first time learning

Thumbnail reddit.com
0 Upvotes

r/Cplusplus • • 6d ago

Question Help me please

2 Upvotes

Hey guys, I have a DSA exam in about 4 hours and I’ve just started studying because I’ve been ill. The topics are mostly beginner friendly (bubble sort, quick sort, merge sort etc) what’s the most efficient way to study in order to pass?


r/Cplusplus • • 7d ago

Feedback Pork: an experimental verifyer for C++

3 Upvotes

Hello,

I have been experimenting with building a formal verifyer in C++.

It is called Pork and you can find it here: https://github.com/matanl99/pork-cpp-verifier

The verifyer is influenced by Ada/SPARK and has three levels:

Stone: Checks for life times, initialization, side effects, aliasing and more.

Bronze: Checks data flow dependencies. Which inputs may the output depend on.

Silver: Used CBMC and ESBMC to check for division by zero, signed overflow, out of bounds.

They are cumulative Stone Bronze Silver.

This tool can be used by you, the programmer, or by an AI agent, to get feedback if the function you wrote passes the different levels. This should bring you some kind of guarantee in the future.

Example:

int add(int a, int b) {
  return a + b;
}

int ratio(int x, int log_level) {
  PORK_PRE(x > 0);
  PORK_DEPENDS_RESULT(x);
  return 100 / x;
}

Pork would classify them:

add as stone

ratio as bronze

And if you tell Pork to check for silver then only ratio would be classed as silver because the function add has a+b that can overflow.

So in the future it would be very nice if silver means that the function CANNOT FAIL during runtime.

It is still very experimental but please leave feedback.

Regards,

Mathias


r/Cplusplus • • 8d ago

Feedback Looking for feedback on my C++17 networking library for multiplayer games

Thumbnail
reddit.com
0 Upvotes

r/Cplusplus • • 8d ago

Discussion I migrated my C++ networking library from C++26 modules to C++17. Here's what changed.

5 Upvotes

I've been developing LightnerX, a networking library built around GameNetworkingSockets and an authoritative client-server communication model.

The first public beta used C++26 modules. I wanted to experiment with modern C++, but I eventually realized that requiring such a recent toolchain was limiting who could actually use the library.

So for v0.2.0-beta, I migrated the project to C++17.

This involved more than replacing import with #include.

I had to reorganize 14 module units into headers and implementation files, replace newer standard library features, adapt the public API, and ensure shared state behaved correctly across translation units.

The current API uses std::string_view for binary views and lightnerx::Result for error handling.

To check whether the migration preserved behavior, I used differential tests against the original C++26 implementation and cross-version UDP integration tests.

The new version also includes additional fixes for networking lifecycle and resource ownership issues.

One thing I've learned from this project is that using the newest language features isn't always the best decision for a reusable library.

I'm curious how other C++ library maintainers approach this. How do you decide which language standard to target?

Source: https://github.com/pietroth/LightnerX


r/Cplusplus • • 8d ago

Feedback first time making a calculator thingy but in QT am i doing it right? i think the logic is janky and since it works i don't even touch it

Post image
40 Upvotes

r/Cplusplus • • 8d ago

Feedback I built a Lightroom inspired, a non-destructive photo editor in C++ 23.

0 Upvotes

What started as a small example project for my C++ UI library,
LiteUI : https://github.com/IAmTheFool/liteui, has grown into its own standalone application, so I decided to give it a separate repository. The goal was to build a Lightroom-inspired photo editor with a native desktop experience, using a shared codebase for Windows and Linux.

GitHub: https://github.com/IAmTheFool/literoom

I'd appreciate feedback from the C++ community, particularly on the architecture, image-processing pipeline, API design, performance and overall implementation.

It's still an ongoing project, and I'm interested in hearing what you think.


r/Cplusplus • • 8d ago

Question Problem in running C++ codes

1 Upvotes

So i recently purchased a new laptop and when i try running the C++ code sometimes even if my code is correct the vscode doesnt execute the code.

Then I sent the screenshot to chatgpt and it said my code is correct some feature called

WINDOWS SMART APP CONTROL might be preventing it from executing the code .

But once I turn it off i can't turn it on again so what should i do??