r/cpp_questions 3d ago

OPEN Which meetup you are going next month?

3 Upvotes

like in meetup.com i am want to meet pople online in C++

can u please share the name/link of that meetup.


r/cpp_questions 3d ago

OPEN is sfml game development (the book) manageable for someone with no sfml experience?

0 Upvotes

(title)


r/cpp_questions 4d ago

OPEN what to learn

0 Upvotes

i have always been passionate abt c++ due to the amount of control it leaves on the devs and i am starting, currently learning dsa in this, what should i learn to be industry ready like learning libraries, frameworks, just note the i am only starting and this is literally my first language to my software engineering life. Pls assist. Thank you


r/cpp_questions 4d ago

OPEN Projects that are Resume Worth

15 Upvotes

Hello, I am an intermediate programmer and am looking for advice/guidance on what projects may be resume worthy. I am looking to be employed into the Aerospace/Defense sector and want to get some insight as to what tools, programs and libraries I should familiarize myself with. I am currently in my last semester of Sophomore year majoring in CS.

I am looking to beef up my resume as well as my GitHub profile with programs and code that will give insight to recruiters as to what I may know and how well I know it. I try to refrain from AI so I want to learn the hard way because that's just the way I learn. I use AI to check my program and aid me of course, but when it comes to code, I truly want to learn the craft and not show up to interviews with my hand in my ***.

Languages: C/C++, Python

Any advice would be greatly appreciated, thank you!


r/cpp_questions 4d ago

SOLVED Question about function template instantiation

6 Upvotes

I was wondering why this code behaves this way

main.cpp

#include "foo.h"

int main()
{
    bar(42, foo<int>);
}

foo.h

#pragma once

#include <iostream>
#include <string>

template<typename T>
void foo(T t)
{
    std::cout << "Default\n";
}

template<typename T, typename Foo>
void bar(const T& t, Foo foo)
{
    foo(t);
}

foo.cpp

#include "foo.h"

template<>
void foo(int t)
{
    std::cout << "Int\n";
}

Result

$ g++ main.cpp foo.cpp -O3 && ./a.out 
Default
$ g++ main.cpp foo.cpp && ./a.out 
Int

My guess is that I'm hitting some kind of UB here. The way I think about it, the int template specialization would be discarded, as it is not used in that translation unit, and then main.cpp would pick up the generic template version (basically, the O3 result seems correct to me, but not the non-optimized one). What is actually happening here?


r/cpp_questions 5d ago

OPEN What is the most impressive compile time C++ code you've seen

43 Upvotes

I've recently been laid off so I have been spending a lot more time writing code I want to write. Lately I've taken an interest in actually learning TMP which is something I've been wanting to do, but until now, I've mostly used templates for generic data structures.

So rather than go find videos, tutorials, or traditional learning materials, I decided I would build and optimize a 3DGS library using C++23 and TMP while using AI as a learning tool. Currently, I have built and optimized a forward pass renderer to frame times comparabable with the best publicly available tools.

In doing so, I have implemented the following compile time features;

- Static arena memory layout calculations (both on the gpu and cpu)

- Perfectly inlined and unrolled render graph execution with conditional branching. I'd like to implement some form of concurrency also.

- Optimized wrappers around Vulkan Compute types, as many of these values are known at compile time.

- Currently working on an abstraction between the interface and the different backends so they are somewhat interoperable.

The thing is, sometimes I'm not so sure what the LLM is suggesting is the best approach. I will push back and sometimes it gives in. But I can't tell if that's my traditional c++ mindset fighting the process, or if the AI is just not up to date.

So I'm in search of exceptionally written codebases to study. Things with a heavy reliance on C++20/23 and compile time optimizations. What projects come to mind?


r/cpp_questions 4d ago

OPEN Error problem

0 Upvotes

I have been stuck on this issue of 256-bit with with an AES code and I'm trying to configure a few things correctly so I can learn what to do on this project. and I keep getting this error Cannot open include file: 'cryptopp/aes.h': No such file or directory so I have no Idea what I did wrong I looked thru all the code that i know I could find and it still doesn't work


r/cpp_questions 5d ago

OPEN I understand C++ syntax but completely freeze when trying to build logic for assignments. How do I bridge the gap?

20 Upvotes

Hey everyone, I’m a Computer Science student currently taking C++. I'm hitting a massive wall with my problem-solving skills and need some advice. Before this, I felt very comfortable with the fundamentals. I know how to build logic using if/else statements, how to use loops (for, while, do-while), and I fully understand how to write and use functions. I also understand what classes are and can do small tasks with them.

However, once my assignments and projects started requiring me to create my own classes and functions to solve a larger problem, that’s where I really started struggling, I get completely confused about where to start. I understand the C++ syntax itself, but I struggle to figure out how to take a text description and actually implement it into a structured program using classes, how to structure code, what variables I need, and how many functions I need. My mind just goes blank trying to map out the algorithm.

If you used to struggle with the problem-solving side of programming rather than the language syntax, how did you train your brain to break down problems? How do you figure out 'where to start' when reading a textbook assignment?

Also, recommendations for any good online resources, YouTube videos, or websites that are great for learning C++ logic?

Thanks in advance for any tips!


r/cpp_questions 5d ago

OPEN Minimize temporaries when adding std::arrays

11 Upvotes

I have a bunch of code of the form (sometimes in more convoluted fashion)

using aVec = std::array<double, 32>;
aVec a, b, c, d, e;      // some are constexpr, others runtime values
double x, y;
for ( int i = 0; i < 32; ++i)
  a[i] = x * b[i] + y * c[i] + y*y*d[i] + e[i];

I'd like to rewrite it such that a = x * b + y * c + y*y*d + e; to generally be easier to read intent, but I don't want all of those operations to create & destroy a bunch of temporary std::arrays.

Is there any straightforward way to achieve this? These generally lives in the inner (or mid-level) loops.

Only thing I could think of is to have the addition & scalar multiplications operators return a proxy type that is essentially a fixed-length std::vector that implicitly converts to std::array. It'll be a bit slower than the code I'm trying to replace, but the move semantics should reduce that impact.


r/cpp_questions 5d ago

OPEN Why are Contracts disliked?

16 Upvotes

I’ve seen a lot of discussions online discouraging their usage bit I never managed to grasp why since it’s sometimes vague.
I do understand it doesn’t replace validation and it’s more of a syntactic sugar to the existing casserts, but any other critiques?
Thanks


r/cpp_questions 4d ago

SOLVED Passing 'this' keeps causing errors and I don't understand why

0 Upvotes

I'm trying to make a simple text adventure and am at my wits end with the errors. I am trying to make a state machine to handle states for title, combat, etc so i am trying to pass the state machine to the state so it can tell the state machine what the next state might need to be. If anyone has any suggestions that would be appreciated.

Here are some of the errors it's throwing:

-syntax error: identifier 'CurrentGameState'

-'GameState::Action': function does not take 2 arguments

-syntax error: missing ';' before '*'

-missing type specifier - int assumed. Note: C++ does not support default-int

https://pastebin.com/hsvnwiyy


r/cpp_questions 4d ago

OPEN Am I doing c++ wrongly or the docs are incomplete?

0 Upvotes

Hello,

I need some guidance.

I will explain my problem with an example:

/include/comm/http_server.hpp:75:25: error: no matching function for call to ‘imdecode(boost::beast::http::basic_string_body<char>::value_type&, cv::ImreadModes, cv::Mat*)’
  75 |             cv::imdecode(req.body(), cv::IMREAD_COLOR, &img);
     |             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/../CVCPP/tmp_codes/tests/dev/../../../include/comm/http_server.hpp:75:25: note: there are 2 candidates
In file included from /home/../CVCPP/tmp_codes/tests/dev/../../../include/comm/http_server.hpp:17:
/home/../CVCPP/opencv/install/Linux/include/opencv5/opencv2/imgcodecs.hpp:612:18: note: candidate 1: ‘cv::Mat cv::imdecode(InputArray, int)’
 612 | CV_EXPORTS_W Mat imdecode( InputArray buf, int flags );
     |                  ^~~~~~~~
/home/../CVCPP/opencv/install/Linux/include/opencv5/opencv2/imgcodecs.hpp:612:18: note: candidate expects 2 arguments, 3 provided
/home/../CVCPP/opencv/install/Linux/include/opencv5/opencv2/imgcodecs.hpp:639:16: note: candidate 2: ‘cv::Mat cv::imdecode(InputArray, int, Mat*)’
 639 | CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst);
     |                ^~~~~~~~

In this example, from the error, I realize that there is no overload or conversion defined (completely reasonable) for the type boost::beast::http::basic_string_body<char>::value_type& to cv::InputArray. The official docs provide some information.

Now, looking at the docs, I don't know if it's even safe to pass a raw pointer, or if there is some other sort of conversion possible.
One possible solution could be ChatGPT, which I don't want to do because I will forget it, and the next time I need to deal with such a problem, I cannot do it unless I have access to something like ChatGPT.

So, dear experts, what is wrong with my approach here? I would appreciate any insight.

PS: It is clear that I know some basics about C++, but I am not that experienced in it.


r/cpp_questions 5d ago

OPEN Boa noite galera

0 Upvotes

Boa noite galera.

Queria aprender c++ para desenvolvimento de dispositivos embarcados, principalmente voltado para redes.

Se tiver algum com experiência por favor me indique como fizeram para estudar e conseguir desenvolver as técnicas para conseguir projeto códigos para roteadores, firewall e etc


r/cpp_questions 6d ago

OPEN System programming

61 Upvotes

I am starting to learn system programming(c++). As a beginner please recommend me the best project to work with so that it will force me to go on the depth as well as for the strong portfolio?


r/cpp_questions 5d ago

OPEN Need help how to learn C++ and tools for project

2 Upvotes

Hello, I want to make a little Tamagotchi toy as a gift, but my only coding experience is taking AP CSA, so I only know Java. I downloaded Arduino, but I don't know where to start learning C++. This is also my first project outside of schoolwork, so I don't know how to start. I also don't know what to buy to make this happen. I want it physical, and I have zero tools, but I really want to learn how to make this happen!! I want to be an engineer when I'm older, so this would be a good start for me. I apologize if this post seems out of order. One final thing I also dont know if i'm in the right community to post this in so if you know please direct me. Thank you in advance!!!


r/cpp_questions 5d ago

OPEN How do I make an Application?

11 Upvotes

I am making a game in c++ and I want it to be a proper game with an app icon and it being able to open when double clicked etc. For most of my games its just a .exe file that i usually run from the terminal or click on the .exe which then opens the terminal and runs the game, I dont want that for this game. I plan to publish it on my itch.io page and i want it to be a complete application compatible for all platform(or at least one platform without the terminal popup). I make my games using raylib on a macbook using c++11 or c++17 how do i achieve the no terminal application??


r/cpp_questions 5d ago

OPEN release asserts C++17

4 Upvotes

In Windows SDK 10, assert looks like ```

ifdef NDEBUG

#define assert(expression) ((void)0)

else

_ACRTIMP void __cdecl _wassert(
    _In_z_ wchar_t const* _Message,
    _In_z_ wchar_t const* _File,
    _In_   unsigned       _Line
    );

#define assert(expression) ((void)(                                                       \
        (!!(expression)) ||                                                               \
        (_wassert(_CRT_WIDE(#expression), _CRT_WIDE(__FILE__), (unsigned)(__LINE__)), 0)) \
    )

endif

``` And I assume if I wanted to write one for portability and GCC/linux builds I would have to implement some kind of macro that knows a bit about the linux libraries (which I know very little about at all). I also almost never run debug binaries on linux/Ubuntu (we don't support anything else officially) so I would never learn of any assertions that would fire there.

I keep seeing posts about implementing a macro like assume or assert_always, but for the simple use case of printing out an expression or filename in event of a crash I don't know where to start to roll my own when the examples I see are not buildable nor explained down to a level I can grasp.

I'm tempted to just go ```

ifdef WIN32

define assume(expression)

... ``` and lift the above code verbatim. And then do the same on my Ubuntu machine on the other side of the WIN32 guard for portability on both platforms?

But even reading that code I confuse myself, I see it is calling _wassert(_CRT_WIDE(#expression), _CRT_WIDE(__FILE__), (unsigned)(__LINE__)), 0) after a short-circuit boolean evaluation before the || boolean. And have two questions, what is the extra ,0) at the end doing, and what is the !!(expression) having a double bang in front doing? Sorry if this is 2 questions, an answer to either would at least help me frame my knowledge void a bit better.


r/cpp_questions 5d ago

OPEN how to get started in LLVM ?

1 Upvotes

hello guys

I would like to start creating a compiler and language based on LLVM but I know where to start on LLVM

help would be welcome and thank you to all those who will help and answer my question :)


r/cpp_questions 5d ago

OPEN How does std::bind differentiate between arguments and pointer to an object?

0 Upvotes

Hi everyone,

I have difficulties understanding something:

class HttpServer {
    public:
        HttpServer(std::string_view address, uint16_t port):ioc{1},endpoint{boost::asio::ip::make_address(address)},
        acceptor{ioc,{endpoint,port}} {
        };
        ~HttpServer()=default;


        void handle_request() {
            for (;;) {
                tcp::socket socket{ioc};


                // Block until we get a connection
                acceptor.accept(socket);
                std::cout<<"connection accepted"<<std::endl;
                std::thread{std::bind(
                &HttpServer::do_session,this,
                std::move(socket))}.detach();
            }

        }

        void do_session(tcp::socket& socket) {
            //handle request



        }

    private:
        const boost::asio::ip::address endpoint;
        uint16_t port;
        boost::asio::io_context ioc;
        tcp::acceptor acceptor;

    };

In this piece of code, how does std::bind understand that it should infer this as a pointer to the object which own the function pointer (I'm not even sure if I stated it correctly)?

according to chatgpt

std::bind( function, argument1, argument2, argument3 )
is a template that takes a pointer to the function that it should return the wrapper for, along with the arguments and their placeholders. What I don't understand is how it differentiates between the "this" pointer and an argument? How does it know it should take the non-static member function and dereference it based on the address (or reference) of the object that owns it, rather than just using "this" pointer as another argument?


r/cpp_questions 6d ago

OPEN Is C++ Concurrency in Action still up-to-date in 2026 or is there a better resource?

37 Upvotes

r/cpp_questions 5d ago

OPEN Hey guys do you know any library’s that are like raylib for c++ but better in performance I’m using it for 3d

0 Upvotes

Hi guys it become tired to use OpenGL it’s way to much work but currently I’m doing a 3d game project again but it’s everytime the same setting up the OpenGL pipeline writing rederers and shaders this takes so much time everytime so is there a libebary like raylib but using Vulkan instead for better performance because for me it became so boring using opengl and I wana try something new for 3d graphics in pure C++ (beside glsl ore hlsl) thanks for the response


r/cpp_questions 5d ago

SOLVED im new to cpp and wanna know if cpp can do this

0 Upvotes

can you make games just with cpp? as i heard python libraries are made with cpp and i wanna make optimized games that run on like 4gb or 2gb or even 1gb of ram so yeah is there smth like a screen for cpp?


r/cpp_questions 6d ago

OPEN Problem with std::inplace_vector

8 Upvotes

Hello guys! I was curious about the c++26 features and wanted to test the std::inplace_vector

but when i try to use the class it gives me this error: "fatal error: inplace_vector: No such file or directory 6 | #include <inplace_vector>".

What I'm using: Ubuntu 26.04 and g++ 15.2.0.

It's a stupid problem I know but I haven't write c++ code for 2 years and recently i wanted to create a project using c++26.


r/cpp_questions 7d ago

SOLVED As of C++26, what's the recommended way for file IO ?

57 Upvotes

Coming back to C++ after some time. Previously used std::ifstream, std::ofstreamfor trivial file IO. But for a project I need fast file IO and some people suggested not use standard streams !! why is that ?

  1. What do C++ professionals use these days ?
  2. And what are some good practices for reading files : Read all at once or chunked ?

EDIT : I apologize I didn't provide enough info. I want to r/w binary data , windows OS and file sizes are around 50-60 MB


r/cpp_questions 7d ago

OPEN Question about computer architecture or operating systems

7 Upvotes

Hi guys,

I'm a self thaught c++ developer looking to get better by studying all the needed stuff. I studied basic and advanced c++, then now I'm finishing Data structures and Algorithms as my second subject. After I finish the book about dsa, should I study first Operating Systems or Computer Architecture? Mind one thing : I do not care about being an expert on computer architecture, I just wanna know the fundamentals necessary to study everything else. I can't understand what comes first in order of importance for good software. (Please suggest books, they're the only resources that I use cause I learn much better from them rather than online)

Thank you in advance.