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

converting any 8 digit binary number to ascii with very few instructions ( min 1mul , max 4mul )

https://github.com/Mjz86/String/blob/main/uint_conv.md

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

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

C++ - Reddit

C++ inconsistent performance - how to investigate

Hi guys,

I have a piece of software that receives data over the network and then process it (some math calculations)

When I measure the runtime from receiving the data to finishing the calculation it is about 6 micro seconds median, but the standard deviation is pretty big, it can go up to 30 micro seconds in worst case, and number like 10 microseconds are frequent.

\- I don't allocate any memory in the process (only in the initialization)

\- The software runs every time on the same flow (there are few branches here and there but not something substantial)

My biggest clue is that it seems that when the frequency of the data over the network reduces, the runtime increases (which made me think about cache misses\\branch prediction failure)

I've analyzing cache misses and couldn't find an issues, and branch miss prediction doesn't seem the issue also.

Unfortunately I can't share the code.



BTW, tested on more than one server, all of them :

\- The program runs on linux

\- The software is pinned to specific core, and nothing else should run on this core.

\- The clock speed of the CPU is constant


Any ideas what or how to investigate it any further ?

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

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

C++ - Reddit

cppcheck problem

Now that PcLint is no longer available as a single-user license, I'm researching other alternatives that I could use for static analysis (C/C++); one of those is cppcheck...

However, in one of my early test runs, I get this error/warning:

Checking der_libs\\common_win.cpp ...

der_libs\\common_win.cpp:280:4: error: There is an unknown macro here somewhere. Configuration is required. If _T is a macro then please configure it. [unknownMacro\]

_T("Text Files (*.TXT)\\0*.txt\\0") \\

\^

I don't think the actual issue is with TCHAR, because other files in the project use that, and don't give this message... however, I don't know what the actual issue is??

I would note that this text compiles without warnings (g++ -Wall ...), and also passes lint with no warnings...



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

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

C++ - Reddit

Cross compilation isn't worth the pain

I'm convinced c++, ecosystem doesn't want me to cross compile, that I should natively compile on WSL and windows and call it a day.

I have used VStudio, Clion, CMake and XMake. IDE's don't work well even in native compilation, CMake and XMake work without any trouble in native compilation, and they are portable, I can simply run wsl, and run the same commands and my build will be ported to Linux.

But cross compilation doesn't work, I mean you can cross compile a hello world with clang but beyond that it doesn't work. Libraries just refuse to be installed, because they are not designed with cross compilation in mind. Those few who do only support cross compilation to windows from a Linux host, nothing else.

When I started learning this monstrosity, I never would have imagined build systems could have sucked this bad, I thought: Hey syntax might have baggage, but it's fair you can use all manner of libraries. Yeah you can use them reliably if you natively compile everything from source, don't start me talking about package managers, they are unreliable and should be avoided.

Or you can use some of the libraries, if you happen to be using one of the laptops that supports Linux out of the box, you now, the vast majority doesn't.

I'm just frustrated, I feel cheated and very very angry.

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

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

C++ - Reddit

Converting 8digit integers without lookup table ,only by 6 multiplies

https://github.com/Mjz86/String/blob/main/integer_conv.md

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

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

C++ - Reddit

What was our "Ohhhh, I understand it now" moment in C++ ?

Hey guys, I'm student in game development, and I've been studying C and C++ for 2 years now, for me, my "I understand it now" moment was with multithreading, I did not know nor understood how multithreading worked until I started making a mutilplayer game and had to deal with it for making client/server comunication, and it was awesome! What was yours ?

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

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

C++ - Reddit

Need suggestion.

Hey there,

Can anyone suggest me the best way to handle the below scenario.

I used to initilize some data (prerequisites like check file was exists or open the db handle etc.., ) in constructor which is used in member function.

If something went wrong in initilizing the data in constructor. Need to return the error.

Approach 1: pass the dword as reference in constructor arg and get the error code.

Approach 2: raise an exception.

Approach 3: check prerequisites at starting of member function at return the error while accessing the member function.

Using cpp 17

Thanks in Advance.

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

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

C++ - Reddit

Owning and non-owning C++ Ranges // Hannes Hauswedell
https://hannes.hauswedell.net/post/2025/05/17/non-owning-range/

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

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

C++ - Reddit

Cpp interview on smart pointers for straight 1 hour

I got an interview for a mid level position as a dev. Today I gave the interview and the whole interview was :
Give your introduction (5 min)
Smart pointers (55 minutes)
In the beginning I was asked to explain each and why it is used. Later I was given a problem and was asked to identify the problems in the code.
In the beginning of the interview, it was smooth but eventually i blew it during debugging the code.
i forgot the key functions such as lock and expired, which interviewer helped me a bit and I was able to solve his query.
I didn't know the reason why make_unqiue is used which was really a easy answer.
He was not satisfied but I may get next round of interview.
There was also mixed question of array of function pointers, which was cancelled due to end of interview.
Very unexpected, I was waiting for him to change the topic till end.

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

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

C++ - Reddit

An Interesting tool to improving your coding skills

https://github.com/airtucha/codepass

This tool evaluates the maintainability of code and provides recommendations.

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

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

C++ - Reddit

SwedenCpp 0x36: Intro, event host presentation, info - and a (slightly embarrassing) quiz question
https://youtu.be/C-tZVyN1q1U

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

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

C++ - Reddit

Making a Game without Framework

only using windows.h going good right now but is there anyone that has already done it? How was it? How long did it take you?

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

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

C++ - Reddit

First Year CPP Programming Projects

# 200+ hands-on C++ programs covering fundamentals, OOP, Data Structures, and STL — from university first-year coursework

https://github.com/Hussamalibrahim/First-Year-CPP-Programming-Projects.git

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

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

C++ - Reddit

Meaning of C/C++ dawned on me after reading ICU sources

This weekends I was trying to make ICU translate messages via its resource bundle functionality. After some attempts and fruitless feeding on ICU reference documentation, I said myself: "I'm a grown up man, if the docs don't help, I know *The Way*".

And so that's how I ended up diving into this respectable codebase. I can't say it's too bad, although I did find this pearl

for (commonDataIndex = isICUData ? 0 : -1;;) {

But that's not important. While carelessly browsing these mostly C sources back and forth for a couple of hours, it dawned on me. This is the fabled C/C++, that's so often mentioned on job adverts! It does exist!

Basically you have a solid C codebase, but then for one reason or another you add a bit of C++ flavor here and there. You can't use exceptions (haram), you add error codes to C++ constructors (!), you diligently mention that if you want that sweet ABI compatibility you better use the C interface. In the end you have C with extra C++ API to top it or C++ that's written mostly in C style, with gotos and a lot of strcpy. Isn't it C/C++?!

Just a showerthought.

(For reference, I couldn't get what they want to pass as the first argument to `ures_open`: a vague abstract keyword as advertised in the docs or file path that's firmly rooted in the real world.)

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

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

C++ - Reddit

C++ Modules Myth Busting
https://www.youtube.com/watch?v=F-sXXKeNuio

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

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

C++ - Reddit

Concepts vs type traits
https://akrzemi1.wordpress.com/2025/05/24/concepts-vs-type-traits/

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

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

C++ - Reddit

Unified Syntax for Overload Set Construction and Partial Function Application?

Hi all, I was hoping to get some feedback on an idea I've been thinking about. Despite several proposals\[[1](https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1170r0.html)\]\[[2](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3312r0.pdf)\]\[[3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0356r3.html)\], C++ still has no language level support for [overload set](https://en.cppreference.com/w/cpp/language/overload_resolution) construction or [partial function application](https://en.wikipedia.org/wiki/Partial_application). As a result, C++ devs resort to [macros](https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1170r0.html#motivation) to create overload sets and [library functions](https://en.cppreference.com/w/cpp/utility/functional/bind_front) for partial application. These solutions are sub-optimal for many reasons that I won't reiterate here.

I had an idea for a unified syntax for overload set construction and partial function application that I don't think has been previously proposed and that I also don't think creates ambiguities with any existing syntax.

|Syntax|Semantics|
|:-|:-|
|`f(...)`|Constructs an overload set for the name `f`; equivlent to the the `OVERLOADS_OF` macro presented [here](https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1170r0.html#motivation).|
|`f(a, b, c, ...)`|Constructs a partial application of the name `f`. Essentially a replacement for `std::bind_front(f, a, b, c)`.|
|`f(..., a, b, c)`|Constructs a partial application of the name `f`. Essentially a replacement for `std::bind_backf(f, a, b, c)`.|
|`f(a, b, c, ..., d, e, f)`|Constructs a partial application of the name `f`. Essentially a replacement for composing `std::bind_front(std::bind_back(f, d, e, f), a, b, c)`.|

For safety, arguments partial applications are implicitly captured by value, but can be explictly captured by reference using `std::ref` for non-const lvalues, `std::cref` for const lvalues, (the to-be proposed) `std::rref` for rvalues, or (the to-be proposed) `std::fref` for a forwarding reference (e.g. `std:fref<decltype(a)>(a)`). Under hood, the generated overload would unbox `std::reference_wrapper` values automatically.

Here's an example of usage.

std::ranges::transform(std::vector { 1, 2, 3 }, std::output_iterator<double>(std::cout), std::sin(...));

Some notes.

* I chose to use `...` as the placeholder for unbound arguments because I think it makes the most intuitive sense, but we could use a different placeholder. For example, I think `*` also makes a lot of sense (e.g. `f(a, b, c, *, d, e, f)`).
* The proposed syntax doesn't support partial applications that bind non-leading or non-trailing function arguments. IMHO that's not an issue because that's not a common use case.
* The automatic unboxing makes it difficult to forward an `std::reference_wrapper` through the generated overload, but we could have a library solution for that. Something like `std::box(std::ref(a))`, where unboxing `std::box(...)` would result in an `std::reference_wrapper<std::remove_reference_t<decltype(a)>>` value. In any case, this situation is pretty rare.

Would be really curious to hear what others think about this idea, esp. any obvious issues that I'm missing. Thank you!

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

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

C++ - Reddit

Objective-C or C++?

Both are just very painful for App Development (especially a GUI).

I'd personally use something more high level like Kotlin or Swift (depending on the platform), just for simplicity sake.

But if you were to build an entire app just with Objective-C or C++, which would be faster, easier to maintain, better support (long term)?
C++ has better syntax (and is a much easier language to work with), but objective-c is what most components in MacOS are built on.

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

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

C++ - Reddit

Learning fundamentals with C++.

Hi,


I am an experienced programmer, but have mostly written production code in higher level languages. The most I have experienced with C++ was during my undergrad days for one year (13 years ago). I want to dive deep into lower level programming. Please let me know what projects and where should I start? Are there open source smaller projects that I can begin with and move onto bigger projects? I recently read the book CODE, and now I want to dive into programming.

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

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

C++ - Reddit

Compressing int values to the smallest possible space

I am working on a drone project using esp32 boards. Where one board is a controller and the other one is the drone. I am sending a variable for each direction of each analog stick on the controller as number values plus a packet number. Wich makes for 5 uint8t vars. I need each packet to be as small as possible to increase range and latency i saw something called bitpacking wich is about shoving multiple values to one variable. I dont understand this concept so need your help please. What i want to have is one variable with values ranging from 0 to 100 another 3vars ranging from 0 to 50. Any idea on how i could put all those values in the smallest possible place and could they fit in a single uint16t?

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

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

C++ - Reddit

Visualizing entire Chromium include graph
https://blog.bkryza.com/posts/visualizing-chromium-include-graph/

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

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

C++ - Reddit

Is banning the use of "auto" reasonable?

Today at work I used a map, and grabbed a value from it using:

auto iter = myMap.find("theThing")

I was informed in code review that using auto is not allowed.
The alternative i guess is:
std::unordered_map<std::string, myThingType>::iterator iter...

but that seems...silly?

How do people here feel about this?

I also wrote a lambda which of course cant be assigned without auto (aside from using std::function). Remains to be seen what they have to say about that.

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

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

C++ - Reddit

What's your favorite part about working in c++?

For me personally, it's the sheer freedom and control it gives you. I've yet to have the language tell me "no, that's not allowed" and I think it makes things a lot more enjoyable. Feels like you get to really think about your solutions and how to make them work best for you.

What's your favorite part?

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

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

C++ - Reddit

Rust Devs Think We’re Hopeless; Let’s Prove Them Wrong (with C++ Memory Leaks)!
https://www.babaei.net/blog/rust-devs-think-we-are-hopeless-lets-prove-them-wrong-with-cpp-memory-leaks/#a-_crtdumpmemoryleaks-demonstration

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

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

C++ - Reddit

Can’t run my codes (cpp) on vs code in macbook

I am a beginner. Watched a couple of videos on YouTube but can’t run the cpp code on vs code. Its asking for ‘“ select a debug configuration “. Then after selecting one it says unable to perform this section because process is running.

I don’t know what to do, should I reset and do it again?

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

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

C++ - Reddit

Rust devs have the Borrow Checker, we have _CrtDumpMemoryLeaks() to hunt down Memory Leaks
https://youtu.be/mmUAdCzrdmQ

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

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

C++ - Reddit

CForge v2.0.0-beta: Rust Engine Rewrite

CForge’s engine was originally created in Rust for safety and modern ergonomics—but with v2.0.0-beta, I've re-implemented the engine in native C and C++ for tighter toolchain integration, lower memory & startup overhead, and direct platform-specific optimizations.



**Why the switch?**



* **Seamless C/C++ integration**: Plugins now link directly against CForge—no FFI layers required.

* **Minimal overhead**: Native binaries start faster and use less RAM, speeding up your cold builds.

* **Fine-grained optimization**: Direct access to POSIX/Win32 APIs for platform tweaks.



**Core features you know and love**



* **TOML-based config** (`cforge.toml`) for deps, build options, tests & packaging

* **Smarter deps**: vcpkg, Git & system libs in one pass + on-disk caching

* **Parallel & incremental builds**: rebuild only what changed, with `--jobs` support

* **Built-in test runner**: `cforge test` with name/tag filtering

* **Workspace support**: `cforge clean && cforge build && cforge test`



**Performance improvements**



* **Cold builds** up to **50% faster**

* **Warm rebuilds** often finish in **<1 s** on medium projects



Grab it now 👉 [https://github.com/ChaseSunstrom/cforge/releases/tag/beta-v2.0.0\] and let me know what you think!



Happy building!



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

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

C++ - Reddit

Announcing Traeger 0.2.0, now with Rust bindings (and Python and Go).

Traeger is a portable Actor System written in C++ 17 with bindings for Python, Go and now Rust.

https://github.com/tigrux/traeger

The notable feature since version 0.1.0 is that it now provides bindings for Rust.

The Quickstart has been updated to show examples in the supported languages.

https://github.com/tigrux/traeger?tab=readme-ov-file#quick-start

For version 0.3.0 the plan is to provide support for loadable modules i.e. to instantiate actors from shared objects.

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

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

C++ - Reddit

IDK whether I should post this here But I got tired of typing #include <vector> so I wrote a C++ tool that does it for me. Now I can blame myself more efficiently.
https://github.com/Ashind-byte/BlameMySelf.hpp

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

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

C++ - Reddit

First C++ project
https://github.com/HIGGS317/Tov_cpp

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

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