Category "c++"

Where and why do I have to put the "template" and "typename" keywords?

In templates, where and why do I have to put typename and template on dependent names? What exactly are dependent names anyway? I have the following code: t

GDB doesn't work: Cannot insert breakpoint 1. Cannot access memory at address [...]

I'm trying to setup my vscode to debug C++ programs using gdb from WSL. But I faced problem with gdb on my WSL 1 (Ubuntu 22.04 LTS). Whenever I try set a breakp

Why {} is better candidate to be int than string for C++ overload resolution? [duplicate]

Overload resolution favours to consider {} as being of some fundamental type as opposed to some container. For example: #include <iostream&

Explanation of C++ FAQ's unsafe macro?

According to the C++ FAQ, macros are evil: [9.5] Why should I use inline functions instead of plain old #define macros? Because #define macros are ev

Explanation of C++ FAQ's unsafe macro?

According to the C++ FAQ, macros are evil: [9.5] Why should I use inline functions instead of plain old #define macros? Because #define macros are ev

Factory method in C++: why additional Creator interface and does factory method need a class?

I am currently unclear what constitutes the Factory Pattern in C++ given many implementations and examples in the wild. https://refactoring.guru/design-patterns

The callstack always shows _errno after strtol in WPA

I'm study WPA. I wrote a simple program and used WPR to collect the etl. My program is very simple, just trying to covert string to int in a loop. #include <

How to assign two or more values to a QMap Variable in Qt

I am getting confused of how to store the values assigned from 3 different functions and storing them in a single map variable QMap<QString,TrainInfo>*Tim

Why conversion from '<brace-enclosed initializer list>' to 'std::tuple<A, bool>' is ambiguous error occurs with GCC 11?

I have the following code #include <tuple> struct A{ int a; int b; }; std::tuple<A,bool> get(){ return {{}, true}; } With GCC 9.* an

Wrapping std::format in a template function fails to compile with the latest MSVC compiler update

I'm a bit stumped as to why this code has suddenly stopped compiling: https://godbolt.org/z/hhM5GG78x But if I change the compiler back v19.31, it will compile:

WebKitGtk doesn't load local files

I've tried loading a local html file using webkit_web_view_load_uri() with a file:// URL. However, the webview would display a blank page. To circumvent this, I

How can I achieve native-level optimizations when cross-compiling with Clang?

When cross-compiling using clang and the -target option, targeting the same architecture and hardware as the native system, I've noticed that clang seems to gen

Pointer to single bytes of vector of doubles

I have vector of doubles and I need to have pointer with access to each single byte (probably char *ptr). Can you tell me how to assign pointer to char to vecto

how to put all the numbers in the white boxes on the chessboardArray, in C++?

I wrote the following code for creating a chessboard using 2D Arrays in C++ : #include <iostream> #include <iomanip> #include <array> using na

Array Processing Employee Records output not correct C++

I have an array processing assignment based on C++ by which the records of each employee presented in a given text file should be calculated and printed as Hour

Define a function signature containing a reference with C++20 Concepts

I am trying to use C++20 Concepts to constrain an interface. In this interface, I want a function signature to only use references. For some reason, I can't do

Why do member functions that overload the + operator typically have 2 arguments when 1 produces the same result? [duplicate]

I've noticed that when people overload the + operator they often use two arguments when I've been able to simply pass in 1 and get the same re

DElem<T,N> derives from BElem<T> and DContainer<DElem<T,N>> derives from BContainer<BElem<T>> How to code it?

The question is easy to explain in code. I have coded several template classes that they derive from a unique template class: template<typename T,unsigned N&

Sampling problem when creating a variable rate shading surface texture with SUBRESOURCE_DATA

I am trying to create a texture2d in d3d11 from std::vector data. This texture is going to be used as the variable rate shading surface texture. For testing pur

How to filter datagridview using multiple checkboxes using ComboBox

I want to filter the datagridview by checking / unchecking one or more of the treeview checkedboxes and should display me the selected item in the datagridview