Category "c++11"

MQTT client waits indefinitely during publish of message

I try to implement an asynchronous MQTT client with the paho library, that receives messages on topic "request", formulates a string and puts the response out o

Error Missing Type specifer - int assumed . Note C++ does not support default init

In order to make two objects, User1 and User2, of a class User sending and receiving messages, #include <iostream> using namespace std; class reply { p

Different values for integer

Trying to insert values of square and cube of a number in set st and st1. (Let n = 10^7). After printing, set st is having negative values due to limit of integ

Why do std::shared_ptr<void> work

I found some code using std::shared_ptr to perform arbitrary cleanup at shutdown. At first I thought this code could not possibly work, but then I tried the fol

How to create a simple version of std::function class

Suppose that I want to create a simple version ofstd::function, which has following behaviors: 1. function(){} -> A void constructor 2. function(_ReturnType,

(declared implicitly) cannot be referenced -- it is a deleted function

With the following code, I'm facing an issue. ABC.h namespace abcd { class ABC { public: ABC() = delete; ABC(const std::string&am

Qt: Qt 6.1.1 Failed to create vertex shader: Error 0x80070057

Guys! I'm a new user of qt and I faced a problem with qml. This issue has already been discussed in this article, but for python. I write in C ++/Qt 6.1.1, QtCr

Accessing variables of main() function inside signal handler in C++

I want to change the variables declared in the main function using signal handler when an user defined signal is sent to the process. I do not want to use any g

Using queue Between two object of class

In order to send messages between two objects of class! I implemeted this class User { public: virtual void run() { while (true)

why the first example in xtensor can't run?

I install the xtensor by conda conda install -c conda-forge xtensor and I find the position where the xtensor is installed, path_xtensor="/amax/home/user/minic

Qt C++ : Cannot instantiate class derived from QAbstractListModel

Using Qt wizzard I created ToDoListModel2 class derived from QAbstractListModel. Code: todolistmodel2.h #ifndef TODOLISTMODEL2_H #define TODOLISTMODEL2_H #incl

Creating folders in C++

I have recently started working in C++ and came across this situation when I have to create a directory while executing my code. The code is working fine when I

How to save/load values from board to file

Im using c++ 11, I need to save/load array to and from file. Its the battleship game its need to be done for both user and computer array but i have no idea how

std::enable_if based on expression using static constexpr member function

Is the following code legal C++11? #include <type_traits> template<typename T> typename std::enable_if<T::Data() == nullptr>::type test (T t

Tensorflow Op: how to include libtensorflow_framework.so?

I followed the instructions of this tutorial: https://www.tensorflow.org/extend/adding_an_op#implement_the_gradient_in_python. There is this comment provided: g

Why is "std::is_pointer<std::nullptr_t>::value" equal to false?

I read about std::is_pointer in C++. Then I wrote the program and check whether T is a pointer type or not using std::is_pointer. #include <iostream> i

Is it legal to define an anonymous struct?

Is the following code legal?: struct { int x; }; This code simply defines an unnamed structure. I do not intend to create objects of this type, nor do I

<command-line>:0:3: warning: ISO C++11 requires whitespace after the macro name

I am compiling qt sources (C++) on different version of Ubuntu OS (14.04 and 16.04 LTS). The sources compile (g++) on 14.04 LTS without warnings. But on 16.04 g

C++: What is the correct cast for offseting to std::vector iterator?

I have a function that takes a std::vector of doubles, and copies them to another vector, but at a particular offset (assume there is sufficient space): void c

Keep getting error message not all control paths return a value

bool isEnemy(const string& check) { if (check == enemy1 || check == enemy2 || check == enemy3) // if the name being checked is an enemy of this kni