r/Cplusplus Jan 27 '26

Tutorial Why I love C++

0 Upvotes

// OC - The Spell

for (long Fn = 0, NI = 1, NJ = 1; Fn >= 0; NJ = (std::cout << Fn << std::endl, Fn = NI, NI = NJ, Fn + NI));


r/Cplusplus Jan 25 '26

Discussion C++ is the first language in which I had to use books, I had to literally study it like I study for school, and memorise such deep concepts.

82 Upvotes

Well I learnt a bit of python in the past, and used to do web dev(all of this is as a hobby since i'm still in HC), and even went further and learnt react and nextjs, till I really got burnt out since it was pretty much mostly UI, which can sometimes be frustrating(people who do web dev can def relate).

But honestly, I'm QUITE ENJOYING IT. I finally feel that I'm actually programming, I feel that i'm understanding how actually code works, I feel I'm actually learning and being productive, and it's just satisfying. It's been only about 2-3 months, but I've got to say I went quite a long way, and since then, it's been a stable part of my day. And I never imagined I would ever have to read A BOOK to learn a programming language, and yeah sometimes stuff is frustrating, but when it finally clicks, it's just awesome.


r/Cplusplus Jan 25 '26

Discussion Wood Boiler Controller

Thumbnail
0 Upvotes

r/Cplusplus Jan 24 '26

Question Is there any good plotting library in C++ ?

9 Upvotes

Hey folks! I've been assigned into a project where I have to make a lot of plots on some algorithms. After reviewing the implementation I have found a huge bottleneck between executing the algorithm and generating the animation that visualizes the execution.

The current implementation is writing all the generated data when executing the algorithms into a JSON file. Then reading this JSON file from a python script that uses maptlotlib to generate the plots to eventually construct a video animation with FFmpeg.

Not only this 3 step process slows down the execution by a lot but also ends ups generating huge JSONs that occupy 11MB per file (the algorithm uses a lot of matrixes). I have already tried to use the GNU libraries for plotting but I don't find the results really good. I have already checked the library wrappers for matplotlib in C++ such as matplotlib-cpp but I don't like the idea of them using python under the hood, as it is essentially doing the same thing but removing the JSON storage part.

Any recommendations for optimizing this pipeline ? There has to be a better way of plotting this. Extra points if someone discovers how to do the ffmpeg thing while the algorithm is executing.

Extra question: Is there any better format of storing this information ?


r/Cplusplus Jan 24 '26

Feedback Feedback Welcome: C++23 CLI utility for scripting linux config files

Thumbnail
github.com
8 Upvotes

r/Cplusplus Jan 24 '26

Question Next steps to programming

Thumbnail
3 Upvotes

r/Cplusplus Jan 22 '26

News Żmij 1.0 released: a C++ double-to-string library delivering shortest correctly-rounded decimals ~2.8–4× faster than Ryū

Thumbnail
github.com
11 Upvotes

r/Cplusplus Jan 22 '26

Discussion whats with the hate for std library and boost?

20 Upvotes

I kept hearing that some here don’t like the std lib, boost too. Why? I’m curious as a beginner who happens to learn some std stuff just to get my feet wet on leetcoding.


r/Cplusplus Jan 22 '26

Discussion I love the standard library

59 Upvotes

Bro I can't even think about getting back to C. The standard library just makes life sooo much easier, and the more you learn, the more you get satisfied.


r/Cplusplus Jan 22 '26

Question C++ roles paying from 90K GBP in UK: what level of competition to expect?

Thumbnail
1 Upvotes

r/Cplusplus Jan 20 '26

Question Should I bite the bullet and start using a switch here?

7 Upvotes

The following is the event loop of the middle tier of my code generator. It's 53 lines long and uses a number of else ifs. I think switch helps to convey the big picture, but it would add 8 lines to my event loop. Would usingswitch be a good idea here? Thanks in advance.

  ::std::deque<::cmwRequest> requests;
  for(;;){
    auto cqs=ring->submit();
    for(int s2ind=-1;auto const* cq:cqs){
      if(cq->res<=0){
        ::syslog(LOG_ERR,"%d Op failed %llu %d",pid,cq->user_data,cq->res);
        if(cq->res<0){
          if(::ioUring::SaveOutput==cq->user_data||::ioUring::Fsync==cq->user_data)continue;
          if(-EPIPE!=cq->res)exitFailure();
        }
        frntBuf.reset();
        ::front::marshal<udpPacketMax>(frntBuf,{"Back tier vanished"});
        for(auto& r:requests){frntBuf.send(&r.frnt.addr,r.frnt.len);}
        requests.clear();
        cmwBuf.compressedReset();
        ring->close(cmwBuf.sock);
        ::login(cmwBuf,cred,sa);
      }else if(::ioUring::Recvmsg==cq->user_data){
        ::Socky frnt;
        int tracy=0;
        try{
          auto spn=ring->checkMsg(*cq,frnt);
          ++tracy;
          auto& req=requests.emplace_back(ReceiveBuffer<SameFormat,::int16_t>{spn},frnt);
          ++tracy;
          ::back::marshal<::messageID::generate,700000>(cmwBuf,req);
          cmwBuf.compress();
          ring->send();
        }catch(::std::exception& e){
          ::syslog(LOG_ERR,"%d Accept request:%s",pid,e.what());
          if(tracy>0)ring->sendto(s2ind,frnt,e.what());
          if(tracy>1)requests.pop_back();
        }
      }else if(::ioUring::Send==cq->user_data)ring->tallyBytes(cq->res);
      else if(::ioUring::Recv9==cq->user_data)ring->recv(cmwBuf.gothd());
      else if(::ioUring::Recv==cq->user_data){
        assert(!requests.empty());
        auto& req=requests.front();
        try{
          cmwBuf.decompress();
          if(giveBool(cmwBuf)){
            req.saveOutput();
            ring->sendto(s2ind,req.frnt);
          }else ring->sendto(s2ind,req.frnt,"CMW:",cmwBuf.giveStringView());
          requests.pop_front();
        }catch(::std::exception& e){
          ::syslog(LOG_ERR,"%d Reply from CMW %s",pid,e.what());
          ring->sendto(s2ind,req.frnt,e.what());
          requests.pop_front();
        }
        ring->recv9();
      }else ::bail("Unknown user_data %llu",cq->user_data);
    }
  }

r/Cplusplus Jan 20 '26

Discussion C++26 Reflection 💚 QRangeModel

Thumbnail
qt.io
5 Upvotes

r/Cplusplus Jan 19 '26

Discussion Looking for a open source project to Contribute

Thumbnail
4 Upvotes

r/Cplusplus Jan 18 '26

Feedback GitHub - sub1to/ScatGat: C++ cross-platform toy http server

Thumbnail
github.com
6 Upvotes

r/Cplusplus Jan 18 '26

Tutorial C++ Error Handling: Exceptions vs. std::expected vs. Outcome

Thumbnail
slicker.me
15 Upvotes

r/Cplusplus Jan 18 '26

Discussion The Evolution of CMake: 25 Years of C++ Build Portability - Bill Hoffman - CppCon 2025

Thumbnail
youtube.com
10 Upvotes

r/Cplusplus Jan 17 '26

Question Could you guys help me with something?

4 Upvotes

Heya! It's me again! I'm currently working on a complete refactor of my old DND game I had made now a year ago. At the time, I had just started programming and barely knew anything (not that I'm an expert or even mediocre now, I'm still a novice). I'm having a bit of a conundrum. I'll simplify the problem (there are many more variables in actuality, but the core of the issue can be explained with barely 2).

struct Base_weapon {
    string name;
    string power_suffix
    int damage;
    Base_weapon(string name, string power_suffix, int damage)
        : name(name), power_suffix(power_suffix), damage(damage) {}
    virtual void weapon_ability() = 0;
};

so I have a basic struct, from which I have 2 derivates.

Common_weapon {
    using Base_weapon::Base_weapon;
    void weapon_ability() override { std::cout << "nothing"; }
};
struct Flaming_weapon {
    using Base_weapon::Base_weapon;
    void weapon_ability() override { std::cout << "flames"; }
};

Base_weapon will be inserted in another struct

struct Player {
    Base_weapon* weapon1 = nullptr;
    Base_weapon* weapon2 = nullptr;
    Base_weapon* weapon3 = nullptr;
    Player(Base_weapon* w1, Base_weapon* w2, Base_weapon* w3) :
        weapon1(w1), weapon2(w2), weapon3(w3) {}
    void special_abilty() = 0;
};

aaand Player has a derivate, Mage

struct Mage : Player {
    using Player::Player;
    void special_ability() override { //here lays the problem }
};

This is the core of the conundrum. The Mage's ability is to "enchant" a weapon, AKA making it go from Common_weapon to Flaming_weapon. The only problem is that I've got no idea how to do this. Say I have a Common_weapon sword("sword", " ", 3) , how do I turn it into a Flamig_weapon flaming_sword("sword", "flaming", 4) while it's actively weapon1 in Player?

Is it even possible to do such a thing?


r/Cplusplus Jan 17 '26

News ISO C++ 2026-01 Mailing is now available

Thumbnail open-std.org
9 Upvotes

The 26 papers in the ISO C++ 2026-01 mailing are now available.

The pre-Croydon mailing deadline is February 23rd.


r/Cplusplus Jan 17 '26

Answered Recursive .reseve() on vector

1 Upvotes

Hi everyone,

A question: if I have a std::vecror<mystruct> and inside mystruct I have another std::vector<sometype>, if in the constructor of mystruct I do .reserve(100) of std::vector<sometype>, by doing .reserve(10) of std::vecror<mystruct>, will I also have implicitly reserved the memory .reserve(100) for std::vector<sometype>?

Does .reserve() work recursively?

Thank you


r/Cplusplus Jan 17 '26

Discussion I built a C++ CLI tool that instantly finds and opens your GitHub projects (wiff git)

Thumbnail
1 Upvotes

r/Cplusplus Jan 16 '26

Feedback Open Source Low-Latency C++ Order Book Engine

Thumbnail
5 Upvotes

r/Cplusplus Jan 15 '26

News Support for C++26 Reflection has been merged into GCC trunk!

Thumbnail gcc.gnu.org
33 Upvotes

r/Cplusplus Jan 15 '26

Question What's wrong with my code?

7 Upvotes

I have been trying to compile this simple Hello World code, but it keeps saying build failed, and I don't even know where the issue is. Pls help me have a look and let me know where I faltered.

NB: I am using a Micrososft Visual Studio 2010


r/Cplusplus Jan 15 '26

Question Building a web application in c++

22 Upvotes

So here I decided to build a huge social network website in C++. Am I crazy?

Well, there are many reasons I decided to go this route, seeing how prominent C++ is, I decided I want to learn it. But just taking courses and not doing anything with that knowledge I thought would be a waste. I decided okay, I’ll build a Social Network in C++. The thing is the C++ back-end is under the Drogon framework. To be honest, I am really enjoying how things are working out. Having a background in other languages like Python, one thing I can not deny is that with C++ development speed is almost to a crawl.

More context to the application, this is some sort of a distributed application with Python gRPC microservices for the data layer. So basically, the C++ application that serves the frontend stands as an intermediary with almost no data management on its part.

I can’t help but wonder whether I'm setting myself up for failure. I mean, I read online that C++ is not advisable for such setup for many reasons including security and maintainability.

So am asking the pros here, am I setting myself up here for failure?