Category "c++"

Two ways of calling coroutines nestedly?

Imagine you have those coroutines awaitable<void> a() { ... } awaitable<void> b() { co_await a(); } awaitable<void> c() { co_await

How to overload == operator? [closed]

I'm using QT to design an app and I can't overload == for a class. Equals works perfectly but == doesn't work and I can't figure out why. Her

How to fix "error: call to 'abs' is ambiguous"

I'm running a simple C++ program from HackerRank about pointers and it works fine on the website. However, when I run it on MacOS, I get error: call to 'abs' is

Implementation of Matlab matrix inverse function in C++ with Eigen

So I need to re-write matrix right-handed division from Matlab to C++: At = (xPow*yPow')/(yPow*yPow'); I mocked some matrices: >> xPow*yPow' ans =

Convert 1 to 01 in C++ without using function

int a; std::cout<<"Enter hour: "; std::cin>>a; std::cout<< a; This is just for question purpose. Is there any trick to output 01 instead of

Convert 1 to 01 in C++ without using function

int a; std::cout<<"Enter hour: "; std::cin>>a; std::cout<< a; This is just for question purpose. Is there any trick to output 01 instead of

Basic example of how to do numerical integration in C++

I think most people know how to do numerical derivation in computer programming, (as limit --> 0; read: "as the limit approaches zero"). //example code for d

Win32 window instances behaving differently

I have created a window class using the win32 api. It creates a window, passing in this as a parameter so that I can create and grab the object instance inside

Euler to Quaternion / Quaternion to Euler using Eigen

I'm trying to implement a functionality that can convert an Euler angle into an Quaternion and back "YXZ"-convention using Eigen. Later this should be used to l

Injecting a Mock using registerConstructor

I've successfully set up a Mock for injection via fruit using .replace(get*Component).with(getMock*Component) like so: #include <gmock/gmock.h> #include

Change page of QstackedWidget with animation

I want to be able to change page of QStackedWidget with some kind of animation (like fade in/out or others...) after some research I find out maybe its possible

What is std::expected in C++?

In one of the most respected stackoverflow answer I found an example of std::expected template class usages: What are coroutines in C++20? At the same time I ca

How to calculate the range of data type float in c++?

As we can see int has 4 byte in memory, that are 32bits, after applying range formula , we can see range of int -2147483648 to 2147483647. I have calculated the

How is CONDITION_VARIABLE implemented?

A longer version of the title question would be: On my machine, sizeof(std::condition_variable) is 72 bytes. What are these 72 bytes used for? Note: The size

non-trivial designated initializers not supported

I have a structure as follows: struct app_data { int port; int ib_port; unsigned size; int tx_depth; int sockfd; char *servername;

Receipt printing via serial port (RS-232)

I'd like to write a c++ program(windows console application) to print receipts from a server (via websocket) to a locally connected(via rs-232) receipt printer(

Is an iterator in C++ a pointer?

Is an iterator in C++ a pointer? The reason I ask is that it seems like nobody completely understands what an iterator is. It's just a "thing" or a "value" they

Why is HANDLE event object assumed valid in thread function?

Why is HANDLE event object(synchronization object which is created by CreateEvent function) in winapi assumed to be valid in thread function? From multithreadin

How To set the size of image more than default value in OpenCV

What is the default frame size of opencv image streaming frame ? If I set Width and height of frame more than default frame size what happens? import cv2 cam

More than one file was found with OS independent path 'lib/x86/libusb.so'

I am using libusb in my android application. When I am trying to build libusb native library then I get below error message, *.so files generated. Error:Exe