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

First cpp/opengl project

it shows all 9 planets orbiting in real time with gravity, and there's a wobbly grid that bends around the planets like space-time.
you can click planets, edit their mass, position, velocity etc and see what happens.

no game engine, just raw opengl + imgui + glm.
learned a lot building it so figured i'd share :)
(i know the UI is kinda broken and there are bugs, but it was fun for a first project)

here's the github if anyone wants to check it out: https://github.com/lucas-santoro/SolarSystemGL

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

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

C++ - Reddit

studyplan.dev has been completely redesigned

I noticed that the creator of https://www.studyplan.dev/ completely redesigned the website. It used to have a bunch of random AI generated pictures on every page, now the website looks really neat.

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

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

C++ - Reddit

cpp.libhunt.net and articles

How to pass moderation of an article on cpp.libhunt.net? Have you published your development articles there?

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

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

C++ - Reddit

CppCast: BrontoSource and Swiss Tables
https://cppcast.com/brontosource_and_swiss_tables/

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

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

C++ - Reddit

Desktop app development in cpp

Hello, I have experienced deskrop app development using qt in 2017 and right now im lost.

since 2018 ive been changing my path into android java and nodejs development. but right now i want to start over develop desktop (mainly windows) apps using cpp or rust and i want to learn again.

i just dont kbow at all which path should i choose, i dont even follow cpp versions.

please advice me on how can i develop windows apps

thank you

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

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

C++ - Reddit

Flortent Castelli: A note about safety
https://youtu.be/LuCfYMg5btI

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

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

C++ - Reddit

wait free programs parallelism clarification

in parallelism you have wait free, and lock free programs … lock free can be done easily by just using compare and exchange with spin locks …

so if each spin lock is on its own pinnned core so no thread context switching cost occurs … does that mean this program is “wait free”?

for those curious see this https://stackoverflow.com/questions/4211180/examples-illustration-of-wait-free-and-lock-free-algorithms

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

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

C++ - Reddit

Non-blocking asynchronous timeout

I understand std::future has blocking waitfor and waituntil APIs but is there a way to achieve timeout functionality without blocking?
Thank you!

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

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

C++ - Reddit

Learning and practicing cpp

Hi everyone, I am about to start my journey learning cpp and I need your help . I saw that everybody here recommend learncpp.com but I wonder where should I practice, I have prior knowledge to programming but I want to build strong foundations for my career . Please recommend me resources for learning and practice

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

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

C++ - Reddit

Looking for C++ projects for portfolio

Hi. I’ve been working as a software engineer for 5 years now. I know the ins and outs of web and mobile development with React, Nextjs and React Native.

However, I’ve actually had a dream of working for Supercell for quite some time. 99% of their engineering positions require extensive knowledge of C++.

It’s probably a difficult switch to the gaming industry, but I’m looking for a few semi small projects to kind of get the feel for C++ and common tools used in that industry. What do i need to learn to make the switch (terms and tools), and what projects would help me get there? Any common games people make for example?

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

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

C++ - Reddit

(areaSq >= areaRect && i < squares.size()) {
                top5.pushback(std::makeunique<VSquare>(squaresi++));
            } else if (j < rectangles.size()) {
                top5.pushback(std::makeunique<VRectangle>(rectanglesj++));
            }
        }

        benchmark::DoNotOptimize(top5);
    }
}
BENCHMARK(BMVirtualFunction)->Arg(1000)->Arg(10000)->Arg(100000)->Arg(1000000)->Arg(10000000);

// -------------------- Benchmark:rust dyn trait like --------------------
static void BM
RustDynTraitLike(benchmark::State& state) {
    sizet count = state.range(0);
    std::vector<Square> squares;
    std::vector<Rectangle> rectangles;

    for (auto
: state) {
        generateShapes(squares, rectangles, count);

        std::sort(squares.begin(), squares.end(), (auto a, auto b){
            return a.area() > b.area();
        });
        std::sort(rectangles.begin(), rectangles.end(), (auto a, auto b){
            return a.area() > b.area();
        });

        std::vector<ShapeView> top5;
        sizet i = 0, j = 0;
        while (top5.size() < 5 && (i < squares.size() || j < rectangles.size())) {
            double areaSq = (i < squares.size()) ? squares[i].area() : -1;
            double areaRect = (j < rectangles.size()) ? rectangles[j].area() : -1;
            if (areaSq >= areaRect && i < squares.size()) {
                top5.push
back(ShapeView{ &squarevtable, new Square(squares[i++]) });
            } else if (j < rectangles.size()) {
                top5.push
back(ShapeView{ &rectvtable, new Rectangle(rectangles[j++]) });
            }
        }

        benchmark::DoNotOptimize(top5);
    }
}

BENCHMARK(BM
RustDynTraitLike)->Arg(1000)->Arg(10000)->Arg(100000)->Arg(1000000)->Arg(10000000);







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

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

C++ - Reddit

Trying to put together a video curriculum for "improving your C++"

Suppose you were a co-worker of a recently-hired junior C++ developer. They've just come out of university, or have had a little programming experience but not with C++ mostly, and now they've been hired. And also suppose, that they will be working in a less-than-ideal environment, e.g. a lot of old legacy code, some other developers whose fluence in modern C++, community norms / "core guidelines", awareness of important FOSS C++ libraries etc. is lacking, code design corner-cutting due to racing towards deadlines etc.

So, you want to try and offer them a perspective, or some educational experience or material, on plying their trade better.

Of course there is more than one approach to going about this, and one-on-one interaction is offer more effective than pointing people in the directin of some self-study, but - I felt that a lot of the recorded, publicly-available talks regarding C++ and its ecosystem have been rather useful and inspiring to me over the years; and - they are relatively easy to experience passively, at one's own pace, with limited requirements from a "mentor" or "proselytizer" behind them.

So, I thought I would try to curate some sort of a loose "curriculum" of such video talks, presented in order - and which doesn't teach people the language basics, but is rather only intended to deepen and widen understanding, hone and polish skills, and inspire mindsets, ideas and sensibilities.

But this is not easy to do, because:

There are just so many available by now! Just the main C++ conferences over the past decade offer hundreds of items; and possible items can come from further afield (like the very nice and well-focused [Stop writing classes](https://www.youtube.com/watch?v=o9pEzgHorH0) talk, which I've found myself sending people, even though it's from PyConf and doesn't mention C++ at all).
A lot of talks/sessions partially cover the content of other talks; and even if the intersection can be small for two videos, when you get to a slate of 10, you can easily find something that's half-covered by the combination of the other items you've found worthwhile.
Even impressive, inspiring talks gradually become a bit dated, as the language evolves. I do want content encouraging people to make use of language constructs introduced in C++11 and C++14, for example; and I remember Herb Sutter's 'tasting' talk from 2014, [Modern C++: What you need to know](https://www.youtube.com/watch?v=TJHgp1ugKGM) - but there have been three new standard versions published since then, so it is now only "Some of what you need to know".


So, my question/request:

Have you had experience putting together a "video curriculum" like this? That you could perhaps share in whole or in part?
If you had to pick a limited number of such video segments, which would obviously not cover every aspect of the language - what would you recommend as particularly likely to inspire programmers better, and to sink in to their minds andf memories?
Do you have any methodical advice regarding my curation process?




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

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

C++ - Reddit

I built a 5MB cron in C++

Standard cron uses 20MB+ RAM and wasn't designed for containers. My C++ alternative uses only 5MB, has structured logging, prevents hanging jobs, and is actually easier to configure (NO external library).

The Problem with Standard Cron in Containers:

Consumes 15-20MB RAM + spawns multiple processes
Cryptic configuration syntax (0 */4 * * * anyone?)
Basic logging that tells you nothing useful
Not designed for containerized environments
Jobs can hang indefinitely

My Solution - ChronoCraft:

Instead of: 0 23
/path/to/cleanup.My syntax: {23, 0, CronFrequency::DAILY, 0, 0, "./Jobs/cleanup", "Daily cleanup"}

What makes it better:

5MB total RAM usage (vs 20MB+ for standard cron)
Self-documenting config \- no more googling cron syntax
Structured logging with execution times and proper error handling
Auto-timeout \- jobs can't hang your system
Single process \- perfect for Docker containers
Thread-safe logging system



GitHub: https://github.com/GiuseppePuleri/NanoCron/

Give me a feedback pls!

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

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

C++ - Reddit

Why does every simple C project need a PhD in CMake sorcery?

I just wanted to compile a hello world, not summon Beelzebuild with a 200-line CMakeLists.txt. Meanwhile, Python folks just sneeze and their script runs. We suffer so they may mock us. Join me, brothers and sisters, in laughing through the pain of dependency hell!

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

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

C++ - Reddit

Clion Free For Non Commercial Use

I am not a student but i am a self learner and i dont know how can i use CLion for non commericial use as it requires a student or teacher

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

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

C++ - Reddit

C# to C++

I’ve been a full stack engineer in the web applications industry, all the way from simple web apps to big data projects, mostly done using C# and web programming languages.

Apart from doing embedded and HFT, what is the most popular industry that heavy uses c++?

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

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

C++ - Reddit

How long to master c++ from Python or other languages

Hello everyone.

I am in transition to going dive into C++, how long it normally takes to master it specially from other languages. also, how to get jobs in C++ developer to improve the skillset.

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

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

C++ - Reddit

I wrote a tool to stop make -j from OOM-killing my C++ builds

Hey everyone,

Like many of you, I often work on large C++ codebases where running make -j with full parallelism is essential to keep build times manageable.

I have a build VM with 32 cores but only 16GB of RAM. When I'd kick off a build, it was a lottery whether it would finish or if the system would spawn too many g++/clang++ processes at once, exhaust all the memory, and have the OOM killer nuke a random compiler job, failing the entire build.

The usual workaround is to manually lower the job count (make -j8), but that feels like leaving performance on the table.

So, I wrote a simple C-based tool to solve this. It's called Memstop, a tiny LD_PRELOAD library. It works as a gatekeeper for your build:

1. Before make launches a new compiler process, Memstop intercepts the call.
2. It checks the system's available memory in /proc/meminfo.
3. If the available memory is below a configurable threshold (default 10%), it simply waits until another job finishes and memory is freed.

This throttles the build based on actual memory pressure, not just a fixed job count. The result is that you can run make -j$(nproc) with confidence. The build might pause for a moment if memory gets tight, but it won't crash.

Using it is straightforward:

# Require 20% available memory before spawning a new compiler process
export MEMSTOPPERCENT=20
LD
PRELOAD=/path/to/memstop.so make -j

I'm sharing it here because I figured other C++ devs who wrestle with large, parallel builds might find it useful. It's a single C file with a Makefile and no complex dependencies.

The code is on GitHub (GPLv3). I would love to hear your thoughts\!

Link: https://github.com/surban/memstop

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

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

C++ - Reddit

Florent Castelli: A note about safety - (Fixed version)
https://youtu.be/VAnlVjrDouA

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

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

C++ - Reddit

Martin Fowler vs Uncle Bob – What's the Right Function Length?
https://youtu.be/hPPFri2zRfw?si=PugMR9aB9LHot2UD

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

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

C++ - Reddit

Library Hardware performance monitoring directly in your C++ code

Hey r/cpp! I'm back with an update on my library that I posted about a year ago. Since then, perf-cpp has grown quite a bit with new features and users, so I thought it's time to share the progress.


What is perf-cpp? It's a C++ library that wraps builds on the perf subsystem, letting you monitor hardware performance counters and record samples directly from your application code. Think perf stat and perf record, but embedded in your program with a clean C++ interface.

Why would you want this? Tools like perf, VTune, and uProf are great for profiling entire programs, but sometimes you need surgical precision. Maybe you want to:

- Profile just a specific algorithm or hot loop
- Compare performance metrics between different code paths
- Build adaptive systems that tune themselves based on hardware events
- Link memory access samples with knowledge from the application, e.g., data structure addresses
- Generate flamegraphs for a specific code paths

The library is LGPL-3.0 licensed and requires Linux kernel 4.0+. Full docs and examples are in the repo: https://github.com/jmuehlig/perf-cpp

I'm genuinely curious what the community thinks. Is this useful? How could it be better? Fire away with questions, suggestions, or roasts of my code!

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

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

C++ - Reddit

Audio Plugin Conventions

Hi all, am creating an audio plugin using the VST SDK. But the query applies to other frameworks also.

Basically, the way these plugins work leads me down some strange coding ways, for example extremely long switch statements (50+ cases) for parameter handling, classes with 100 getters and setters. I was wondering how others handle these strange parts that are simple but become cumbersome purely through amount-of-text.



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

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

C++ - Reddit

Cpp and DSA from scratch in 6 months

Hi,

Can anyone recommend good resources for learning C++ and Data Structures & Algorithms (DSA) from scratch?

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

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

C++ - Reddit

BlueSky

# Is there an active community of C++ programmers on BlyeSky? Do you use this social network?

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

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

C++ - Reddit

2025 AsiaLLVM Developers' Meeting Talks
https://www.youtube.com/playlist?list=PL_R5A0lGi1ADKfJbzpA0rMDCb5T3QGe5k

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

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

C++ - Reddit

why c++ is slower than rust

Quick C++ Benchmarks

#include <benchmark/benchmark.h>
#include <vector>
#include <algorithm>
#include <random>
#include <memory>

// -------------------- virtual function --------------------
struct Shape {
    virtual double area() const = 0;
    virtual ~Shape() = default;
};

struct VSquare : public Shape {
    double side;
    VSquare(double s) : side(s) {}
    double area() const override { return side side; }
};

struct VRectangle : public Shape {
    double width, height;
    VRectangle(double w, double h) : width(w), height(h) {}
    double area() const override { return width
height; }
};

// -------------------- function table --------------------
struct ShapeVTable {
    double (area)(const void);
    void (destroy)(void);
};

struct ShapeView {
    const ShapeVTable vtable;
    void
object;

    ShapeView(const ShapeVTable _vtable, void object)
        : vtable(
vtable), object(object) {}
    ShapeView(ShapeView&& other) noexcept
        : vtable(other.vtable), object(other.object) {
        other.object = nullptr;
    }

    ~ShapeView() {
        if (object) vtable->destroy(object);
    }

    double area() const {
        return vtable->area(object);
    }
};

void generateVShapes(std::vector<VSquare>& squares, std::vector<VRectangle>& rectangles, size
t count) {
    std::mt19937 rng(42);
    std::uniformrealdistribution<> dist(1.0, 100.0);
    squares.clear();
    rectangles.clear();
    for (sizet i = 0; i < count / 2; ++i) {
        squares.emplace
back(dist(rng));
        rectangles.emplaceback(dist(rng), dist(rng));
    }
}

struct Square {
    double side;
    double area() const { return side * side; }
};

struct Rectangle {
    double width, height;
    double area() const { return width * height; }
};

double square
area(const void obj) {
    return static_cast<const Square
>(obj)->area();
}
void squaredestroy(void* obj) {
    delete static
cast<Square>(obj);
}
const static ShapeVTable square_vtable = { square_area, square_destroy };

double rect_area(const void
obj) {
    return staticcast<const Rectangle*>(obj)->area();
}
void rect
destroy(void obj) {
    delete static_cast<Rectangle
>(obj);
}
const static ShapeVTable rectvtable = { rectarea, rectdestroy };

void generateShapes(std::vector<Square>& squares, std::vector<Rectangle>& rectangles, size
t count) {
    std::mt19937 rng(42);
    std::uniformrealdistribution<> dist(1.0, 100.0);
    squares.clear();
    rectangles.clear();
    for (sizet i = 0; i < count / 2; ++i) {
        squares.emplace
back(dist(rng));
        rectangles.emplaceback(dist(rng), dist(rng));
    }
}

// -------------------- Benchmark:虚函数 --------------------
static void BM
VirtualFunction(benchmark::State& state) {
    sizet count = state.range(0);
    std::vector<VSquare> squares;
    std::vector<VRectangle> rectangles;

    for (auto
: state) {
        generateVShapes(squares, rectangles, count);

        std::sort(squares.begin(), squares.end(), (auto a, auto b) {
            return a.area() > b.area();
        });
        std::sort(rectangles.begin(), rectangles.end(), (auto a, auto b) {
            return a.area() > b.area();
        });

        std::vector<std::uniqueptr<Shape>> top5;
        size
t i = 0, j = 0;
        while (top5.size() < 5 && (i < squares.size() || j < rectangles.size())) {
            double areaSq = (i < squares.size()) ? squaresi.area() : -1;
            double areaRect = (j < rectangles.size()) ? rectanglesj.area() : -1;
            if

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

C++ - Reddit

Trip report: C++ On Sea 2025
https://www.sandordargo.com/blog/2025/07/02/cpponsea-trip-report?ref=dailydev

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

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

C++ - Reddit

My first tutorial blog for c++ beginners

Hey guys,

I finally posted my first tutorial for beginners! (https://answer-repo.com/blogposts/1)

Sharing my knowledge and thoughts is something I’ve always wanted to do, but I kept putting it off.

I’m excited to get started and would love to hear your thoughts and feedback.

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

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

C++ - Reddit

Learning C++

Hello everyone,

I recently started learning C++, about two days ago. I created my first project today, a number guessing game — which i'm proud of, but not satisfied with. However, I was wondering how long does it take for an average guy to learn C++ enough to start working on games and softwares. Everywhere i look, i see different answers and i'm very confused.
[I have worked with other programming languages and worked on personal projects before.\]

Have a pleasant time.

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

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

C++ - Reddit

C++26 Reflection as polyfill Clang plugin

I am exceptionally far from being expert in the Clang plugins ecosystem, and just wondering about an idea to have a Clang plugin with the reflection feature only which can be used for older C++ versions like C++20. Is it possible, even is it make sense? Thanks in advance

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

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