Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
43 views

I have the following code to execute a PUT to a given address by means of the restc-cpp library: auto rest_client = RestClient::Create(); auto done = rest_client->ProcessWithPromise([&mess,...
-3 votes
0 answers
78 views

How can I get autoindentation to use Whitesmith style for C/C++ files in VSCode? I use Microsoft C/C++ Extension pack and clang-format. "Format Document" works ok with C/C++ files. There is ...
-1 votes
1 answer
139 views

Can somebody explain what does this code do? template <typename... Types> auto maketuple(Types&&... args){ return std::tuple<Types...>(std::forward<Types>(args)...); } ...
2 votes
1 answer
176 views

I write a cross-platform program for Windows and Linux, and I would like it to behave as similar on both platforms as possible. I use some mathematics in the program, e.g. std::atan2 function calls, ...
0 votes
2 answers
106 views

So the question given to me is to make a C++ program where the user inputs the size (declared by n) of a matrix N x N, and then there's a function for the user to fill the matrix called inputMatrix #...
0 votes
0 answers
43 views

In a previous thread I asked about listing real filenames stored on a Portable Device (e.g. an MTP Digital Camera). Per my answer I can now traverse the file system and display real filenames. Now I ...
0 votes
0 answers
32 views

I have recently tried installing VTK 9.5 on Ubuntu 24.04 from source (latest .tar.gz release) but when I compile a really simple example code the window doesn't show up. I would like my vtk ...
0 votes
0 answers
79 views

Consider this example: #include <thread> #include <atomic> int main(){ std::atomic<int> x = 0, y = 0; auto t1 = std::thread([&](){ if(x.load(std::memory_order::relaxed)==...
2 votes
1 answer
110 views

First of all, Qt version is 6.10.0, testing on Arch Linux rolling. I think I've found a bug in Qt but maybe it's just my fault. My program asks MariaDB database for some data and displays it in ...
0 votes
0 answers
51 views

I'm attempting to narrow a screenshot of an app to a specific section of the UI for later processing by Tesseract; in particular, the X Battle ratings located in the lower half of the image. I did a ...
5 votes
2 answers
124 views

I'm writing a header-only library which defines class X in header x.hpp. The implementation of X is different for different standard versions: #if __cplusplus < 201703 class X { int a; ...
2 votes
0 answers
153 views

According to modern C++ guidelines, we should prefer uniform initialization everywhere, for example: int x{0}; However, when I try to combine uniform initialization with C++20’s designated ...
4 votes
0 answers
196 views
+50

Consider this example: #include <atomic> #include <cassert> #include <thread> int main() { std::atomic<int> strong = {3}; std::atomic<int> weak = {1}; auto t1 ...
Best practices
2 votes
5 replies
127 views

I am trying to generalise a class that can accept different types, but also optionally accept multiple types. The class must use virtual functions. For a single type a specialised class might look ...
Best practices
0 votes
11 replies
204 views

first I must says that I hate templates.... it makes unreadable complex code.... not speaking about 5000000 lines long error messages, with 10000 possibilities and that takes ages to understand for ...
-4 votes
0 answers
109 views

I'm building a Visual Studio solution, consisting out of 54 projects. There are several error lines, the first is: The system cannot find the file '!(bindpath.bin)\somefile.dll'. In the output ...
-5 votes
0 answers
88 views

I am on Windows 11. I downloaded and installed the Vulkan SDK on my Windows machines. When I try to compile, I keep seeing: vulkan/vulkan.h: No such file or directory I have installed: C:\VulkanSDK\1....
Advice
3 votes
7 replies
228 views

Off the top of my head, I only remember LLVM's standard library do this, but I remember seeing other libraries also do this. I'm not entirely sure what is the advantage here. I feel like namespace std ...
-1 votes
1 answer
65 views

The idea is for my Windows app to exchange QUIC data with a browser. Upon creating a server with msquic and nghttp3, I'm not sure why chrome says Failed to establish a connection to https://host.com:...
-3 votes
0 answers
85 views

I am implementing ghost behavior in a Pac-Man clone, specifically the behavior when ghosts are inside the ghost house during the waiting phase. The issue is that ghosts inside the ghost house do not ...
0 votes
0 answers
85 views

I've been working on a C++ project. I have been using 2 Windows PCs for building it and both worked fine with the same (kinda janky) setup. I recently got a new computer and I get a linker error. My ...
-3 votes
0 answers
90 views

I have this part of my code where I have an array and want to compare it with other constant arrays, to find a match. As I am working with Multi-dimensional arrays, I decided to store these constants ...
1 vote
1 answer
93 views

I want to set up a watchdog that checks whether the io_context workers can pick up tasks within a reasonable time and are not stuck running long or blocking operations. To achieve this, I've ...
-3 votes
0 answers
113 views

I have a solution where I need to write a custom allocator that uses a std::vector as storage for the objects allocated with it. I'm using a std::shared_ptr for the std::vector, and I know that it ...
-4 votes
0 answers
78 views

I am trying to use the Open Cascade library to create a model converter (DLL). The Open Cascade library contains many DLLs and Libs I have specified the additional libraries TKDEGLTF.lib TKMesh.lib ...
2 votes
1 answer
132 views

While evaluating thread pool libraries for short-running tasks, I noticed that they all performed significantly worse than OpenMP. The root cause seems to be that other libraries struggle to start ...
2 votes
1 answer
184 views

I am trying to come up with a way to determine, whether a given format string is valid for a given Type at compile time. I was expecting for a simple concept to work: template<typename T> ...
3 votes
1 answer
116 views

Consider the following translation unit: export module Example; export inline void fn1(); export void fn2(); export void fn3(); void fn1() {} void fn2() {} module :private; void fn3() {} Firstly, ...
Advice
1 vote
1 replies
92 views

Why can't we put a constraint on the first type parameter of the concept? Why can't we use the short form of the concept for non-type parameter? Why is it possible to specialize concepts only in ...
0 votes
0 answers
131 views

I'm experimenting with std::unordered_map performance in C++20 and noticed that when I insert a large number of elements, the container sometimes rehashes multiple times even though I called reserve() ...
1 vote
0 answers
61 views

I can draw a rectangle without errors if I use unsigned int or uint32_t in indices[] and I have 2 questions: Why do I get a triangle when using uint8_t? I get nothing if its 2 bytes (uint16_t) ? No ...
0 votes
1 answer
116 views

I want to remove the comma characters inside __VA_ARGS__. I have found a FOR_EACH implementation, which kind of solves it, but gives cluttered error messages when there is a mistake. My problem has ...
5 votes
0 answers
103 views

I am trying to develop a system audio recording application which uses the application loopback method provided by WASAPI. I'm basing my implementation upon the Windows classic samples application ...
-1 votes
1 answer
130 views

I refer to this answer. The example is for the integral type int. Replacing it by a class, the example doesn't work and the expression static int const value = sizeof(f<Derived>(0)); resolves ...
-5 votes
0 answers
110 views

I installed the new Visual Studio 2026, and last I checked reflect.h from reflect-cpp was compiling, but no longer. It gives a internal compiler error C1001. The version I'm using is 18.0.2 (from the ...
4 votes
1 answer
139 views

Given the following three source files (main.cc, a.cc, b.cc): // main.cc #include <iostream> #include <string> std::string get_a(); int main() { std::cout << get_a() << '\n';...
-1 votes
0 answers
54 views

I’m dealing with a repeated crash in a custom Linux application and hoping to get advice or confirmation or suggestion on the root cause. The application connects to an SFTP server, downloads a daily ...
0 votes
0 answers
37 views

I'm trying to debug memory issues on an embedded Linux system (C++ application). I want to use jemalloc for it. I managed to build jemalloc and link my sample application against it, and it detects ...
5 votes
2 answers
114 views

I have a QColumnView with a QFileSystemModel attached to it, and I am trying to get information on what file is being hovered over in that model view. I do have mouse tracking enabled, however it ...
11 votes
1 answer
657 views

Consider the following simplified code: template <class T> class Foo { T t; const T* t_ptr; public: constexpr Foo(T t): t(t), t_ptr(&this->t) {} constexpr Foo(const Foo&...
0 votes
1 answer
67 views

On Regex101, I have simple Regex with a named capture group in ECMAScript flavor: (?<name>.*) I'm trying to do the same thing in C++: #include <iostream> #include <regex> using ...
Best practices
3 votes
9 replies
220 views

In a framework that makes use of the std::int* types (such as std::int16_t) as well as the std::int_fast* types (such as std::int_fast16_t) there could be general rules where one could be better than ...
9 votes
1 answer
487 views

Consider this code: #include <cstddef> #include <iostream> const double cash = 1000; int main() { size_t my_size_t_value = 2; double my_double_value = -my_size_t_value*...
Best practices
2 votes
8 replies
187 views

I need to define several constant strings that will be used across an entire C++20 project. I am considering the following options : constexpr char[] str1 = "foo"; constexpr std::string str2 ...
0 votes
0 answers
86 views

This question is a follow-up of std::bit_cast padding and undefined behavior. This "revival" is motivated by my answer to Accessing object storage where I proposed a function to modify a ...
9 votes
1 answer
617 views

I noticed a discrepancy between C++23 and C++26 code when using googlemock: enum A { A1, A2 }; enum B { B1, B2 }; TEST(...) { ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26 ASSERT_THAT(...
2 votes
0 answers
126 views

Consider this example: #include <iostream> #include <atomic> #include <thread> #include <cassert> int main(){ std::atomic<int> val = 1; std::atomic<std::atomic&...
Best practices
1 vote
8 replies
181 views

Say I'm developing a C++ command line tool of moderate scope. I have a couple dozen classes, and a main() driver function that lets the user do a few things with the tool. I could have one .hpp and ...
1 vote
1 answer
95 views

Suppose I have a unity build: //impl1.h //impl1.cpp -> #include s impl1.h //impl2.h //impl2.cpp -> #include s impl2.h AND impl1.h //main.cpp #include "impl1.cpp" #include "impl2....
2 votes
0 answers
51 views

I’d like to know whether it’s possible to change the background color of a wxButton when the mouse is hovering over it. On Windows, I tried handling the enter/leave window events, but it seems the ...