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

SFML or SDL

I'm planning to do a game engine as my final paper, so i started searching about game engines and c++ libraries and frameworks that i could use. Most of the results were talking about SDL and SFML, which one would you recommend to work with? Whether for learning, practicality, performance or any other reasons

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

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

C++ - Reddit

Boost version 1.89 released!

One new library and updates to 12 more.
Download: https://www.boost.org/releases/1.89.0/
Bloom, configurable filters for probabilistic lookup: https://boost.org/libs/bloom

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

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

C++ - Reddit

Ever learned of new C++ features from linter warnings?

TIL of using enum from a linter warning. I learned about defaulted comparisons this year from this source too. Is it just me uneducated C++20 neophyte or others have these moments too?

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

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

C++ - Reddit

Managing Settings with Boost.PropertyTree
https://www.youtube.com/watch?v=1xkEklFIPNc

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

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

C++ - Reddit

Codegen: best way to multiply by 15

Should be simple enough but no compiler seem to agree, at least on x64:
https://godbolt.org/z/9fd8K5dqr
A bit better on arm64:
https://godbolt.org/z/zKaoMbexb

Not 100% sure which version is the fastest, but GCC "shift then sub" looks the simplest (with theoretically lower latency then "imul").
What's a bit sad is that they tend to go out of their way to impose their optimization, even when we explicitly write it as shift then sub.
Is there a way to force it anyway?

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

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

C++ - Reddit

A standalone library to parse C++ type names/declarations

Link: https://github.com/meshinspector/cppdecl

I made a library to parse C++ type name strings (without any context information), manipulate the resulting types, etc. Think https://cdecl.org/, but in library form, and with better C++ support.

The most down-to-earth usecase is probably getting type names as strings in a saner format. Cppdecl includes a bunch of normalization rules ("std::__cxx11::basic_string<char, ...>""std::string", etc), to try to make the names more readable and consistent across compilers.

I also use this for code generation, both to create new types, and to parse types libclang throws at me (without using libclang itself).

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

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

C++ - Reddit

Thoughts on creating a tracking pointer class, part 2: Using a std::list
https://devblogs.microsoft.com/oldnewthing/20250812-00/?p=111454

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

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

C++ - Reddit

Why doesn't every project just statically link libc++?

Libc++ is already small, with LTO application size is nearly identical. I just don't understand why so many projects want to use the system libc++ rather than building and linking their own.

Aren't we already including the runtime in most compiled languages other than C/C++?

When you depend on system libraries anything can happen, something that might have worked on Ubuntu might not work on Debian

Now take the next part with a grain of salt, because I don't know if it is true.

I believe zig cc does this, it ships with libc++ and clang and sysroots and everything just magically cross compiles.

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

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

C++ - Reddit

Open Source High Performance Computing Projects for studying

I am currently a student and interested in HPC and HFT, so I was wondering if there were any open sourced big/legacy projects that I can study. All the projects that I have developed till now have been in modern c++ (c++11 and above). I wanted to study some legacy projects so that I might understand the differences in coding practices in older vs modern projects.

Thank You.

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

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

C++ - Reddit

Am I just dumb or is the CMake tutorial incredibly confusing??

Hi there!

I wanted to do things right this time, and get more accustomed to reading the docs instead of some quick'n'easy tutorial to get a better grasp of the subject matter. So I started following this tutorial from CMake, shown by this link: https://cmake.org/cmake/help/latest/guide/tutorial/A%20Basic%20Starting%20Point.html#exercise-1-building-a-basic-project

But for some reason, this tutorial has become such a pain in the ass to follow. The way the tutorial phrases things are often ambiguous to me, like the part about configured header files. (what is the input file here? And what is the output file?)

And the inclusion of todo's is nice. But what is the point of doing those to-dos when they don't show you how to write those commands syntactically correct without showing the answer, leading me to google things that the tutorial should be covering instead.

I have not even finished step 1 yet and feel incredibly confused to the point of yeeting out the official tutorial and instead picking up some book which covers the topic thoroughly and clearly instead.

So yea... Am I the only one feeling like this or are there others who feel what I am feeling r?
I'd love to know...

Cheers!

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

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

C++ - Reddit

cppreference 2019 offline archives 404

It looks like the offline 2019 version of the cppreference is down. Anyone got it?

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

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

C++ - Reddit

Need advice on sockets , crypto libraries and some design choices

Hey reddit , I find myself here to hopefully plan out a side project , for which I figured out this could be a good place to seek advice.

This project's main focus is going to be around 'end to end encryption (E2EE)' , along with other cryptographic algorithms ( like hashing , diffie Hellman key exchange , X3DH etc which I'll add once I make a bare bone version first)

Before coming down to this , I've been horsing around with the GMP library and implemented diffie-Hellman key exchange , along with a simplified variant of Pollard’s p - 1 algorithm.

The thing i haven't figured out yet , is i want this project to be a functional one , meaning it should be able to communicate and connect to other computer.

One thing that's completely alien to me is Socket programming . This will completly be a new side of C++ for me , and to add to it , the APIs seem to be platform specific , Meaning Windows and Linux based OS would need to be worked on differently.

on doing some research , i realised that i can hand the part of Socket programming to Python which sounds like a fairly good option. the problem being i haven't used python for a scale of something like this yet and secondly i believe C++ is what 'just works' with me. i have never bothred being good in python.

Second option being , i learn the socket programming in CPP itself , make different version for Windows and Linux based OS . This is the part where it starts to feel like climbing a mountain.

what Initially came to my mind as " i could finish this in 3 days " now seems more complicated.
as per my research (chatGPT) , i've several options for hashing libraries , namely
1. OpenSSL
2. libsodium
3. Crypto++
4. Botan

i'd love to know your opinions on these.

Questions :

1. should i opt for python to handle the Socket programming part , or Just Raw dog it in C++ ?
2. What libraries i should consider to implement hashing and crytographic funtions ?
3. what are some design pitfalls i should avoid ?
4. if anyone has worked on something which is related to these , what have been your learnings and advices ?


Any advice or Suggestion is welcomed ;)

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

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

C++ - Reddit

A C++ cron at Bologna Airport
https://github.com/GiuseppePuleri/NanoCron

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

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

C++ - Reddit

I'm currently learning C++, but I'm struggling to break down the learning path.


I'm currently learning C++, but I'm struggling to break down the learning path.
When I was learning C, I followed a simple process: I read from books, watched tutorials, and then solved problems. That worked well.

However, with C++, this approach isn't working for me. For example, when I try to learn just the string type in C++, I find that it has 20–30 different functions associated with it. The same applies to vector and other STL components. This makes it overwhelming, and I don’t know which functions to focus on or how to practice them effectively.

I'm following the NPTEL "Programming in Modern C++" tutorial and reading the book The C++ Programming Language by Bjarne Stroustrup. The NPTEL tutorials are good, but I noticed that they introduce advanced topics like sorting algorithms in lecture 4 and data structures like stacks in lecture 5.

This jumps ahead quickly, and I’m left wondering:
What should I actually do after watching each tutorial? What kind of problems should I solve?

Right now, I don’t have a clear direction or system for practicing.



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

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

C++ - Reddit

A Library Approach to Constant Template Parameters
https://brevzin.github.io/c++/2025/08/02/ctp-reflection/

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

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

C++ - Reddit

C++20 Modules: Practical Insights, Status and TODOs

https://chuanqixu9.github.io/c++/2025/08/14/C++20-Modules.en.html

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

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

C++ - Reddit

Any news on constexpr parameters

Why isn't no one picking constexpr parameters paper up instead of creating new types like std::nontype std::constantwrapper and std::integralconstant this seems like a mess.



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

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

C++ - Reddit

Public Domain | I wrote an archival format.

tl;dr Repository here.

A long running project of mine is a cross-platform legacy 3D engine for making games like Rayman 2 or Playstation 2 style games for Linux & Windows. It's more of a loose collection of libraries which can be used together or separately. My archival format, ReArchive is one of those libraries. I'm releasing it today under the Unlicense use for any purpose for any reason with or without credit.

A simple API 10 functions is provided to interact with the archive files, along with a CLI program which doubles as the demo. It's thread-safe, handles endianness, and is resilient to crashes like if your program crashes during or after writing. ReArchive.h also includes doxygen style notes.

Detailed explanation of how it works:

At the beginning of the archive, There is a header which contains the "Magic" how we identify the file as a ReArchive and the "File Table Offset". The file table, a list of files inside our archive, Is always the last thing in our archive. Each file in our archive has an entry in this file table and immediately preceding where the file is written in our archive. It contains std::filesystem::path which is used to retrieve it, the size in bytes, and the distance from the beginning of the archive to the start of the file.

When a file is written to our archive, We seek to where the file table starts and overwrite it with our file. Then, the position we're at after is our new file table offset in the header. The new file table is written upon the archive being closed. The reasoning for it being this way is so that unless we're deleting a file, We never have to loop over the entire file table to do anything. When you open an archive, You are returned a pointer to the FileTable that is valid so long as it's open. This design is incredibly fast.

If the archive is not closed after writing, My library is aware of this and will walk through the archive and rebuild the file table with the entries that precede each file. If the program or computer crashed during writing, My library is also aware of this and you will only lose the partial file that was being written when crashing.

Things I plan to improve:

return shared pointer to FileTable instead of raw pointer when opening to avoid pointing to trash data after the archive is closed.

Function to read a portion of a particular file in the archive such that it'd be easier to stream things.

Any further performance optimization I can find.

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

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

C++ - Reddit

Modifiable executable?

Is it possible to write a program which can run normally when compiled but if any global modification is done to the executable (mirroring, rotation, etc) then it executes some other code in the same binary?

I know that headers can cause issues but we can always replicate those bytes after compiling in some other unused section of the binary so after modification it acts like the original compiled version

Any specific articles or papers I can look into for this kind of stuff

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

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

C++ - Reddit

[[rescope]] - Floating an Idea for the Standard Library

Follow up to my previous post: https://www.reddit.com/r/cpp/comments/1mmnbkh/how_to_contribute_to_the_standard/

Because the first step is to "float the idea", I have asked myself if floating an idea here would not be a lot more fruitful than directly submitting it. Attending several meetings to discuss, defend, re-defend the idea seems indeed far-fetched for me.

See below

My questions really are:

- What kind of criticism would a proposal like the one below be met with?
- Does anyone see any chance for something like that to make it into any future version of C++?

(Note: the merit of the name "rescope" can for sure be discussed)

---
`[[rescope]]` is a new proposed attribute that would allow a variable to escape the current scope and be seen as it was defined in the previous scope. It can never escape a "closed" scope like a function.

This, ideally, would only be available to variables defined inside an `if constexpr` block.

Without rescope, the variable `dist` in the following snippet needs to be defined with a specific type before it can be used in the entire function. This variable does actually only need to exist and be used in the function if the `if constexpr` evaluation is `true`.

```
template<typename T, typename U>
auto
n_of(T first, T last, ssize_t n, const U &upred, const bool at_least = false) {
typename std::iterator_traits<T>::difference_type dist;

if constexpr (std::random_access_iterator<T>)
dist = std::abs(std::distance(first, last));

for(; n >= at_least and first != last; ++first) {
if constexpr (std::random_access_iterator<T>)
if (dist-- < n)
break;

n -= static_cast<bool>(upred(*first));
}
return not n;
}
```

Had we fist declared the variable with `auto dist = std::abs(...`, it would have later not been available for the `if (dist-- <n)` check happening below (also guarded by an `if constexpr`)

With `[[rescope]]`, the initial definition is no longer needed and `dist` can also be declared using `auto`.

```
template<typename T, typename U>
auto
n_of(T first, T last, ssize_t n, const U &upred, const bool at_least = false) {

if constexpr (std::random_access_iterator<T>)
[[rescope]] auto dist = std::abs(std::distance(first, last));

for(; n >= at_least and first != last; ++first) {
if constexpr (std::random_access_iterator<T>)
if (dist-- < n)
break;

n -= static_cast<bool>(upred(*first));
}
return not n;
}
```

One could also conceive using `[[rescope]]`, for example, in a `for` loop. This allows declaring the variable and later using it as a return value.

```

for([[rescope]] auto i = 0; i < LIMIT; i++) {
// do things here
}

return i == LIMIT;
```

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

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

C++ - Reddit

Corner cases in std::optional initialization
https://gist.github.com/ckwastra/b92858e99a55bc822471cfb42b5f0f2e

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

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

C++ - Reddit

Use concepts with std::remove_cvref_t
https://www.sandordargo.com/blog/2025/08/13/use-concepts-with-remove_cvref

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

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

C++ - Reddit

New C++ Conference Videos Released This Month - August 2025

**C++Online**

2025-07-28 - 2025-08-03

* Tips and Tricks for Improving C++ Legacy Codebases - Roth Michaels - C++Online 2025 - [https://youtu.be/D8TVX1HGn6M](https://youtu.be/D8TVX1HGn6M)
* Optimizing SPSC Lockfree Queue - Sarthak Sehgal - [https://youtu.be/Zg5wuEExY8M](https://youtu.be/Zg5wuEExY8M)
* So You Wanna Delve Into C++? - Honey Sukesan - [https://youtu.be/cUbxzuu6yPQ](https://youtu.be/cUbxzuu6yPQ)

**ACCU Conference**

2025-07-28 - 2025-08-03

* Safe and Readable C++ Code: Monadic Operations in C++23 - Robert Schimkowitsch - [https://youtu.be/YUHbPDNtdiQ](https://youtu.be/YUHbPDNtdiQ)
* Regain Benefits from Agile Software Development - Jutta Eckstein - [https://youtu.be/Tno88QyHT6Q](https://youtu.be/Tno88QyHT6Q)
* Optimizing for Value - Fight Failure Demand With Bottlenecks - Willem van Den Ende - [https://youtu.be/OtPR1u6yVDM](https://youtu.be/OtPR1u6yVDM)

**ADC**

2025-07-28 - 2025-08-03

* LLVM’s Real-Time Safety Revolution - Tools for Modern Audio Development - David Trevelyan & Chris Apple - [https://youtu.be/b\_hd5FAv1dw](https://youtu.be/b_hd5FAv1dw)
* “Engine-Swap” on Two Spatial Audio Plugins Will Be Easy, Right? - Lessons Learned - Domenico Stefani - ADC 2024 - [https://youtu.be/da2G\_lCuJSs](https://youtu.be/da2G_lCuJSs)
* Pipewire: The How, What and Why of Audio on (Embedded) Linux - Daniel Strübig - ADC 2024 - [https://youtu.be/w7xe46-hhQU](https://youtu.be/w7xe46-hhQU)

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

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

C++ - Reddit

timer resolution for mac

is there timer res for mac?

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

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

C++ - Reddit

Getting into C++ in 2025

I recently watched the new F1 movie and I got hooked by the technology and the systems used under the hood. Did some research and unsurprisingly most of them are written in C++. I want to learn it so can you guys tell me how do I get into C++ and what to start with and how to proceed with C++. And is there a market for it in 2025?

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

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

C++ - Reddit

C++ Show and Tell - August 2025

Use this thread to share anything you've written in C++. This includes:

* a tool you've written
* a game you've been working on
* your first non-trivial C++ program

The rules of this thread are very straight forward:

* The project must involve C++ in some way.
* It must be something you (alone or with others) have done.
* Please share a link, if applicable.
* Please post images, if applicable.

If you're working on a C++ library, you can also share new releases or major updates in a dedicated post as before. The line we're drawing is between "written in C++" and "useful for C++ programmers specifically". If you're writing a C++ library or tool for C++ developers, that's something C++ programmers can use and is on-topic for a main submission. It's different if you're just using C++ to implement a generic program that isn't specifically about C++: you're free to share it here, but it wouldn't quite fit as a standalone post.

Last month's thread: https://www.reddit.com/r/cpp/comments/1lozjuq/c_show_and_tell_july_2025/

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

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

C++ - Reddit

Running non-trivial C++ on Cloudflare WASM
https://saus.app/blag/cpp-on-cloudflare-wasm

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

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

C++ - Reddit

Which C++ version does the Switch 2 SDK support?

And in general, which C++ version should we target to be able to easily build for all modern console?

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

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

C++ - Reddit

What's the best way to handle animation frame events/functions

I'm working in SFML and I have an animator class that can loop and returns true when it finishes, but I want to be able to give some frames functions to do and not just check for loops. I'm still new to SFML and C++ so I'm not sure how to go about this with popular engine functionalities in a memory and speed efficient manner

bool Animation::update(float deltaTime, sf::Sprite& sprite) {
// returns true if reached final frame in animation
time += deltaTime;

if (time > framescurrentFrame.duration) {
time = 0;

currentFrame++;
if (loops && currentFrame >= frameCount) return true;
currentFrame %= frameCount;

sprite.setTextureRect(framescurrentFrame.rect);
}

return false;
}

// Animation.h
struct AnimationFrame {
sf::IntRect rect;
float duration;

AnimationFrame(sf::IntRect rect, float duration);
};

struct Animation {
int currentFrame;
float time;
bool loops;
sf::Texture texture;
std::vector<AnimationFrame> frames;
int frameCount;

Animation() = default;
Animation(std::string spritePath, int frames, int framerate, int textureSizes2, int cellSizes2);

bool update(float deltaTime, sf::Sprite& sprite);
void start(sf::Sprite& sprite);
};

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

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

C++ - Reddit

Is there any way to get used to CPP?

Hi everyone,

I'm professionally software developer using Kotlin (9 years).

For my hobby time I'm playing around game dev, specifically Unreal Engine. I know that Unreal's CPP isn't fully same experience as in regular CPP, but I think question is still valid. No matter how much and how small scope I tried to use CPP, I quickly become overwhelmed by two files for single class and so on.

Does anyone also come from high level languages? How to deal with it? I refuse to believe that I'm too old to learn new skill 30 years old, I'm still kid xD). And is it okey to have such experience at all?

I see that all game dev is generally based on C++, so I need somehow to adapt to it, I just don't know how..

Thank you in advance!

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

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