Category "c++"

How can I generate a tuple of N type T's?

I want to be able to write generate_tuple_type<int, 3> which would internally have a type alias type which would be std::tuple<int, int, int> in thi

CMake - How to stop building every dependency every time I build my project

I have a cmake list file that is pulling in dependencies via ExternalProject_Add. On initial compilation of my project (which uses these dependencies) I would e

Error: Cannot open include file: 'MQTTAsync.h': No such file or directory

OS -Windows 10 x64 Library mqtt Microsoft Visual Studio Community 2017 Version 15.9.15 Programming Language - C++17 Installed paho-mqtt paho-mqttpp3 paho-mqt

How to overload << operator for thread-safe logging in C++?

I'm writing a sketch of a simple thread-safe logging library and some things came on my mind. Here's the code: #ifndef SimpleLogger_H #define SimpleLogger_H #

How does const auto and auto const apply to pointers?

I was try out some code and am wondering how the const qualifier in C++ applies to pointer types when using auto. int main() { int foo = 1; int bar = 2;

C++ Difference between std::ref(T) and T&?

I have some questions regarding this program: #include <iostream> #include <type_traits> #include <functional> using namespace std; template

Find average, maximum and minimum values of values entered

The first part of the question is to write a program that: prompts user to enter integer values and keep a running total. #include<iostream> using n

Why Touchscreen don't work with WebAssembly?

I'm developing an webassembly application that must use touchscreen. I studied the examples: dials fingerpaint knobs pinchzoom (see https://doc.qt.io/qt-6/touch

How to set a breakpoint in gdb for an anonymous namespace?

In my code base, there are some callbacks functions which are defined in anonymous namespace. I am debugging in gdb and I want to set breakpoint in the function

How to generate random binary numbers 0 or 1 with length of N and with option to control the probability of having 0 or 1?

I want to generate random binary numbers (0 or 1) having N length size. The tricky part is that, It should be able to control the probability of having either m

print the unordered map values when key value is given as input

I have written the code to read the string values and mapped as key and value. Now I am facing issue in printing the values, if we have given key value as input

Anaconda confuses C/C++ linker with duplicate libraries

This is happening on a Linux system. Anaconda comes with several C libraries, like libz, or libgomp. I have most of these libraries also installed globally on m

Is there still a need to provide default constructors to use STL containers?

I remember that back in C++98, if you wanted to make an STL container of MyClass, you needed to provide default constructor to MyClass. Was this specific to som

Step Into (F11) doesn’t enter some functions in Visual Studio 2015

Inaprogram downloaded from Normal Estimation Using Integral Images. I would like to step into computeFeature (output). The program will not step into t

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