Category "c++"

Defining an atomic<> as a static variable inside a function

C++11 mandates that static variables inside a function are atomically initialized for the first run of the function. The only way to do that efficiently is doub

c++ build error, redefinition of static variable, undefined element

I writing application using c++ and Qt. I have a problem with building application. I get many error but everything refers to static variable and undefined func

Recomended formating for temporarily inverting data at pointer and then passing pointer to temporarily inverted data

Long story short, I have a pointer to a value that is stored inverted, so when we are calculating a hash to verify data integrety, we need to invert the data th

Sorting vector of blocks C++ SFML

I just wanted to make a little program to sort blocks using selection sort, but it doesn't sort itself. Blocks just keep switching places in some pattern, until

Tiff Windows Imaging Component c++

I am trying to replace libtiff into WIC (since libtiff is not able to pass Black Duck Analysis tool anymore) I have used their example https://docs.microsoft.co

Two sinks logger as default logger not working

I'm trying to combine two sinks: auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>(); console_sink->set_level(spdlog::l

push_back element to vector in class object isn't working

classObject and vector within it. I made a vector of classObject and function that searches classObject with a given int id. Wanted to search certain classObjec

Visual studio 2019 Google test nuget package restore failing

I have this error when I try to open some students' assignments in Visual Studio 2019, stating that nuget can't restore a package. I'm concerned about the direc

How to get the value of a template class?

I'm trying to get the value of a template class. To get the value of a class, I can easily do like: int get_value() { return *this; } But I want to create

How to address the "Lock was destructed while held" Visual C++ runtime assertion

In a program that uses DirectX to render a 3D component I use a dedicated rendering thread that apparently gets created if I call DispatcherQueueController::Cre

Problem creating dll and loading then in Python ctypes

I want to learn to create DLLs in c++ and use them in python to increase the speed of calculations. To begin with, I tried to create a simple C++ dll and load

Difference between !(n & 1) and n & 1 == 0 in C++

For some reason in C++, the expressions if(!(n & 1)) and if(n & 1 == 0) seem to not be equivalent. Can someone please explain why this happens?

If there is a difference between two constructs

If there is a difference between two constructs I would like to know std::string name = std::string("Eugene"); and std::string name = "Eugene";

Bitshifting a uint64_t gives wrong result

As was said in the title, bitshifting a uint64_t type gives wrong results. I have absolutely no idea why this is the case. It seems like on the edges of the shi

What is this weird colon-member (" : ") syntax in the constructor?

Recently I've seen an example like the following: #include <iostream> class Foo { public: int bar; Foo(int num): bar(num) {}; }; int main(void) {

Save template type parameter pack for later use

I'm working on a code where I can bind events and callbacks to react to those events, the interface looks like this: void on_close(); struct S { void the_a

How to set rgb colored symbol on specific pos (Win terminal)?

Iam making terminal game but iam struggling with the render part, i want to set symbol on specific pos with rgb color. so first question is how to set symbol in

Why are function pointers and data pointers incompatible in C/C++?

I have read that converting a function pointer to a data pointer and vice versa works on most platforms but is not guaranteed to work. Why is this the case? Sho

Mask from bitfield in C++

Here's a little puzzle I couldn't find a good answer for: Given a struct with bitfields, such as struct A { unsigned foo:13; unsigned bar:19; }; Is the

How to draw QRubberBand on a QGraphicsView using Mouse?

I have my MainWindow with a GraphicsView on which I want to draw a QRubberBand using MouseEvents. Therefore I created a custom GraphicsView class where I have t